From patchwork Mon Feb 27 18:02:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94561 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp976475qgi; Mon, 27 Feb 2017 10:03:13 -0800 (PST) X-Received: by 10.200.52.52 with SMTP id u49mr16111663qtb.101.1488218593536; Mon, 27 Feb 2017 10:03:13 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m20si12386756qta.241.2017.02.27.10.03.13; Mon, 27 Feb 2017 10:03:13 -0800 (PST) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 148D863621; Mon, 27 Feb 2017 18:03:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E9717635FD; Mon, 27 Feb 2017 18:02:54 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 63C2E60C9D; Mon, 27 Feb 2017 18:02:52 +0000 (UTC) Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by lists.linaro.org (Postfix) with ESMTPS id 5760C60AF6 for ; Mon, 27 Feb 2017 18:02:51 +0000 (UTC) Received: by mail-wr0-f177.google.com with SMTP id g10so57734084wrg.2 for ; Mon, 27 Feb 2017 10:02:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cq1HaAZzE75b0bEjjdiY+kkiVPuJsMaqDqoCHutjMe4=; b=q8H0du1/LSO3RGEZWrpast0M9DbjDUMjvKUs0G5fjVIEU5etDsRDiRerntK8m1uS0Q yr+K85VPWgoJXoxCy/ITLZNaoKZEfMhNHARjhYj9Rok1hX7IhskYaHFeRZAqYbutYzAg oCad2qoH+fzqeHQPbwiDikRMz9E15nIyitKO7zRUHwtGjSVu1/mVqSj1cU+UD2dnHzwx 7vFX2WHLr98q7NiDB60TS/mpgFsGUpWVtarBVL6DUWzUcRguP+BgA3/4SUlvB0Ea+q+H RLAgjfJv74IuHyHAorho3vMwTqADuhST0+oe05MfiC+tPXrfsSXLdHbgccjiKdDwQNT/ FLVg== X-Gm-Message-State: AMke39kPZJUof0HjMnDrCUBx2a62xjSUwoFkYnWFg9dv5audtsxza4V95PG/sd5GBuIZIZhksQY= X-Received: by 10.223.175.15 with SMTP id z15mr12444487wrc.84.1488218570467; Mon, 27 Feb 2017 10:02:50 -0800 (PST) Received: from localhost.localdomain ([105.149.201.216]) by smtp.gmail.com with ESMTPSA id v72sm12668569wmd.0.2017.02.27.10.02.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Feb 2017 10:02:49 -0800 (PST) From: Ard Biesheuvel To: linaro-uefi@lists.linaro.org, leif.lindholm@linaro.org, alan@softiron.co.uk Date: Mon, 27 Feb 2017 18:02:29 +0000 Message-Id: <1488218551-6372-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488218551-6372-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488218551-6372-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [Linaro-uefi] [PATCH 1/3] Platforms/AMD/Styx/PlatformSmbiosDxe: don't write to string literals X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" Remove the code from PlatformSmbiosDxe that writes to a string literal to turn the string 'L# Cache' into L1/L2/L3, and just emit the three versions instead. This is necessary given that string literals are emitted into .rodata by default, which makes them read-only when strict memory permissions are in effect. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- Platforms/AMD/Styx/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Platforms/AMD/Styx/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platforms/AMD/Styx/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c index 5ee5d92fdf9c..14e3cc409dbc 100644 --- a/Platforms/AMD/Styx/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c +++ b/Platforms/AMD/Styx/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c @@ -355,8 +355,16 @@ SMBIOS_TABLE_TYPE7 mCacheInfoType7 = { CacheAssociativity2Way // Associativity }; #if (FixedPcdGetBool (PcdIscpSupport)) -CHAR8 *mCacheInfoType7Strings[] = { - "L# Cache", +CHAR8 *mCacheInfoType7StringsL1[] = { + "L1 Cache", + NULL +}; +CHAR8 *mCacheInfoType7StringsL2[] = { + "L2 Cache", + NULL +}; +CHAR8 *mCacheInfoType7StringsL3[] = { + "L3 Cache", NULL }; #else @@ -710,7 +718,6 @@ CacheInfoUpdateSmbiosType7 ( dstType7.SocketDesignation = 1; // "L# Cache" // L1 cache settings - mCacheInfoType7Strings[0][1] = '1'; // "L# Cache" --> "L1 Cache" SmbiosT7 = &mSmbiosInfo.SmbiosCpuBuffer.T7L1[0]; dstType7.CacheConfiguration = SmbiosT7->T7CacheCfg; dstType7.MaximumCacheSize = SmbiosT7->T7MaxCacheSize; @@ -723,10 +730,9 @@ CacheInfoUpdateSmbiosType7 ( dstType7.ErrorCorrectionType = SmbiosT7->T7ErrorCorrectionType; dstType7.SystemCacheType = SmbiosT7->T7SystemCacheType; dstType7.Associativity = SmbiosT7->T7Associativity; - LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7Strings); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7StringsL1); // L2 cache settings - mCacheInfoType7Strings[0][1] = '2'; // "L# Cache" --> "L2 Cache" SmbiosT7 = &mSmbiosInfo.SmbiosCpuBuffer.T7L2[0]; dstType7.CacheConfiguration = SmbiosT7->T7CacheCfg; dstType7.MaximumCacheSize = SmbiosT7->T7MaxCacheSize; @@ -739,10 +745,9 @@ CacheInfoUpdateSmbiosType7 ( dstType7.ErrorCorrectionType = SmbiosT7->T7ErrorCorrectionType; dstType7.SystemCacheType = SmbiosT7->T7SystemCacheType; dstType7.Associativity = SmbiosT7->T7Associativity; - LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7Strings); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7StringsL2); // L3 cache settings - mCacheInfoType7Strings[0][1] = '3'; // "L# Cache" --> "L3 Cache" SmbiosT7 = &mSmbiosInfo.SmbiosCpuBuffer.T7L3[0]; dstType7.CacheConfiguration = SmbiosT7->T7CacheCfg; dstType7.MaximumCacheSize = SmbiosT7->T7MaxCacheSize; @@ -755,7 +760,7 @@ CacheInfoUpdateSmbiosType7 ( dstType7.ErrorCorrectionType = SmbiosT7->T7ErrorCorrectionType; dstType7.SystemCacheType = SmbiosT7->T7SystemCacheType; dstType7.Associativity = SmbiosT7->T7Associativity; - LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7Strings); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7StringsL3); #else LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7, mCacheInfoType7Strings); #endif