From patchwork Thu Jan 31 11:51:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 157139 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7111367jaa; Thu, 31 Jan 2019 03:51:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN4vbZI0xsGwFO7qGEqHMmgLSIkNG47ieOdhnDAttEZ7flyvSue9P+NZi7vdcJXPeg41hQgl X-Received: by 2002:a62:db41:: with SMTP id f62mr35135284pfg.123.1548935515049; Thu, 31 Jan 2019 03:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548935515; cv=none; d=google.com; s=arc-20160816; b=SITrhnA8/vbFOkOkT0915N+UHCsqQXEZF40r6zpFeHGwb4xWsOi+65By/gCcDxzeQY 9YV0yVcO8/r25IODoHkO+GbQ36JxnFDtwZRR6NAyMkuSRjLeZWjCdepq+KxvDu11GBdT uK+M8xqjmk9C++CR46sn/UqFcb0+CzDiq7lwiJzzHAKWFErkZhkD4fqUpEAKni1OJirV gggkbvXUNdDJE1ELmGqYJInMMPKjqSA2MCVl0DvEvBqybkWhyRY8lee2m19CxJl2aCqO gN6WavljvPZW0GMsZSaaGsxMuBGClXHGeG72UTp/GBiROocT0JfE/6kH5yP+kol1TdNO eljQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4/VoXADw9TGpzOH4HUtc8S5BN+42h6eZM7HvNc5Yxz4=; b=l6k4ZUAqOLoqXW4gsBQ5t2sg4yD9kQL4jZl5WHaDu3f4l3P4cHynTe5TzGU6PHknyW cKOtD65EVY1y4c5ccW/PbjnwezAoamleGNBkjvcb1uH1cpkkl/MSJBwDOAb4kEPsh65b t6Zxi/0tECn5PqlRL5vdb3TLtcbt7XeNTFvTY+PWLBhn9PMDrmgNcDefDKc+0+ChWv1G RCK0TsFSQPssXhXVnkS+2cebxwtyr9z1jxC1fS9yxAjE9yneg95CMeUDR6R/h2WuqGcY /HpL7+thX90td/dzOxMTzsW0RXyowgR8N6HCoijYy61xxeoftNrmFF5P3n/xlCeaLl2K Lbxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hkKGJRhU; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z67si4322247pfb.268.2019.01.31.03.51.54; Thu, 31 Jan 2019 03:51:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hkKGJRhU; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730454AbfAaLvy (ORCPT + 3 others); Thu, 31 Jan 2019 06:51:54 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33064 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727189AbfAaLvy (ORCPT ); Thu, 31 Jan 2019 06:51:54 -0500 Received: by mail-wr1-f66.google.com with SMTP id p7so2992955wru.0 for ; Thu, 31 Jan 2019 03:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4/VoXADw9TGpzOH4HUtc8S5BN+42h6eZM7HvNc5Yxz4=; b=hkKGJRhUXfkhPW+avct+oPnArS8giyN/dEKIuCONEk4ShmT0Fz21/8a3dWm4ZSPVbA EDAYKN2j817R09yoDKUYTusd3oARfQe/6sgpJR6ndle2AS/vudHKrfa79wrg3L57fZTa b36KKOLKOOaD6VR+jQMFxUaab/HWTv8vS7/uM= 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:mime-version:content-transfer-encoding; bh=4/VoXADw9TGpzOH4HUtc8S5BN+42h6eZM7HvNc5Yxz4=; b=Dgy7Px70nq3DcohGVvhk0Jzxc4mZkEG0QoNteVGEA9hCzUrbtD32X61qQQLK9b7jpL D4NeYT1cKfQNPDnL/fOyIVkc3F7KLBKdgCKIr543Uy/FovJDG0aysUMjekJcmJ7VEdc4 6rOKpCJFsDIhOG6VJdEvuK18LqOy8UX4FYS4N3tt2VqudeRqH/vq+e7VYTax4okxhZHG al+oBCH3orne3R493+G/zEvh27T+t1YDiuaoPwZcP5mFLTQh5lld7/b3sGQs9RpOp16N 4JUuzWaM4UHmfrGWlcZ//ETeN+frtYxhS+KXONa3CFq7BCf0yPvHfu9oAnVq+FzMqxms glMQ== X-Gm-Message-State: AJcUukf3UPvht3mEnQvfZA3mlfpJZV4k2U8jt0JhYX2YTkzER+m/ahvZ IFuM22QHCKJuS7v6YQk92kudf6NuP3Y= X-Received: by 2002:a5d:530a:: with SMTP id e10mr35201107wrv.151.1548935512133; Thu, 31 Jan 2019 03:51:52 -0800 (PST) Received: from localhost.localdomain (aputeaux-684-1-39-7.w90-86.abo.wanadoo.fr. [90.86.94.7]) by smtp.gmail.com with ESMTPSA id w10sm5807714wmb.1.2019.01.31.03.51.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 03:51:51 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, x86@kernel.org, Ard Biesheuvel , corbet@lwn.net, leif.lindholm@linaro.org, graeme.gregory@linaro.org, mingo@redhat.com, tglx@linutronix.de, linux-doc@vger.kernel.org, agraf@suse.de, pjones@redhat.com Subject: [PATCH v3 1/2] x86: make ARCH_USE_MEMREMAP_PROT a generic Kconfig symbol Date: Thu, 31 Jan 2019 12:51:44 +0100 Message-Id: <20190131115145.4634-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190131115145.4634-1-ard.biesheuvel@linaro.org> References: <20190131115145.4634-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Turn ARCH_USE_MEMREMAP_PROT into a generic Kconfig symbol, and fix the dependency expression to reflect that AMD_MEM_ENCRYPT depends on it, instead of the other way around. This will permit ARCH_USE_MEMREMAP_PROT to be selected by other architectures and other subsystems, such as earlycon for efifb in a subsequent patch. Note that this will cause the encryption related early memremap routines in arch/x86/mm/ioremap.c to be built for 32-bit x86 as well, which triggers the following warning: arch/x86//mm/ioremap.c: In function 'early_memremap_encrypted': >> arch/x86/include/asm/pgtable_types.h:193:27: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '9223372036854776163' to '355' [-Woverflow] #define __PAGE_KERNEL_ENC (__PAGE_KERNEL | _PAGE_ENC) ^~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86//mm/ioremap.c:713:46: note: in expansion of macro '__PAGE_KERNEL_ENC' return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC); which essentially means they are 64-bit only anyway. However, we cannot make them dependent on CONFIG_ARCH_HAS_MEM_ENCRYPT, since that is always defined, even for i386 (and changing that results in a slew of build errors) So instead, build those routines only if CONFIG_AMD_MEM_ENCRYPT is defined. Signed-off-by: Ard Biesheuvel --- arch/Kconfig | 3 +++ arch/x86/Kconfig | 5 +---- arch/x86/mm/ioremap.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/arch/Kconfig b/arch/Kconfig index 4cfb6de48f79..9f0213213da8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -885,6 +885,9 @@ config HAVE_ARCH_PREL32_RELOCATIONS architectures, and don't require runtime relocation on relocatable kernels. +config ARCH_USE_MEMREMAP_PROT + bool + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig" diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 15af091611e2..09c2c5600579 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1510,6 +1510,7 @@ config AMD_MEM_ENCRYPT bool "AMD Secure Memory Encryption (SME) support" depends on X86_64 && CPU_SUP_AMD select DYNAMIC_PHYSICAL_MASK + select ARCH_USE_MEMREMAP_PROT ---help--- Say yes to enable support for the encryption of system memory. This requires an AMD processor that supports Secure Memory @@ -1529,10 +1530,6 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT If set to N, then the encryption of system memory can be activated with the mem_encrypt=on command line option. -config ARCH_USE_MEMREMAP_PROT - def_bool y - depends on AMD_MEM_ENCRYPT - # Common NUMA Features config NUMA bool "Numa Memory Allocation and Scheduler Support" diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 5378d10f1d31..0029604af8a4 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -705,7 +705,7 @@ bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size) return arch_memremap_can_ram_remap(phys_addr, size, 0); } -#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT +#ifdef CONFIG_AMD_MEM_ENCRYPT /* Remap memory with encryption */ void __init *early_memremap_encrypted(resource_size_t phys_addr, unsigned long size) @@ -747,7 +747,7 @@ void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); } -#endif /* CONFIG_ARCH_USE_MEMREMAP_PROT */ +#endif /* CONFIG_AMD_MEM_ENCRYPT */ static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;