From patchwork Sat Feb 2 09:41:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 157332 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1509996jaa; Sat, 2 Feb 2019 01:41:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IayXKUuhsb4vZEv0fFLnoYgOjIN0e4dQknE12PPSDr63Hm+ezGbHf6civFTA+Olvbb7bA6s X-Received: by 2002:a63:1013:: with SMTP id f19mr5622336pgl.38.1549100508309; Sat, 02 Feb 2019 01:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549100508; cv=none; d=google.com; s=arc-20160816; b=Jr+K/IxTh1jy+SMPaYJpj8DmNCto8dGD/E9eVNkd8MTdTYW8jCNzUGRjcqrrpGHEfS q3W/ukpeykgpWByTV1B1LyX4pKkt/YJNpd31EraLrQuTqS6w9vlHE+oM9weVUwVLkoRm f/LNR+sLevXoq4i+UctmE6Zug1v5LzWLQvkFOx6lXIUKFihdLbKnJiXcxlO2RwQwo6T+ fUkm7YE2rlkJBbW9EM7+xUuS39s+NEqHS8OpyaejgrqD3Ccp5+xtCrYYnwwaxUwUpfF9 vP5X85ux2uQ6rqbbxC7TUwqgzG9bB7KD7gkXKVnLfNPdznIk2rmKDyEsHFcP2yNpmPr6 bVbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=iULYkK79KzQBLjCzo7CPIeChw9PmIPBpwpuo29dYAvY=; b=h32kVJe1ERX4CE0g0CWey+JvJ7ljW8sBiQlphSk3izkHVvGMJjNpLPg1PbHaIxzP4u iHRDnzgLcla+WRs40n7h4u5V/lQB/WwQLPFrfnierapCYtwIL/ZqIDtBLTV+LCm8Z/MA PZyOgO5nVDmIAJP4yfbchie2vD/FJ8UQHgcDISnU1rJano7L+iydkYXrzoAI463iALnt v8YdFIppfr8laHM6xEkpL/07Elt4dlJ8KbarlSUKVS9bMPM07DHRS8BVp3JHtR2xobgN A0C1XWN18UHZ5xg9qVIbCficaeZVsy2ukvxG8YoVVn4jl3jlXpgJFhQsbYI8xoSkHVNf ZX7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T3vgkLIZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 c65si10100500pfe.202.2019.02.02.01.41.48; Sat, 02 Feb 2019 01:41:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=T3vgkLIZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727827AbfBBJlq (ORCPT + 31 others); Sat, 2 Feb 2019 04:41:46 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:34305 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727662AbfBBJlk (ORCPT ); Sat, 2 Feb 2019 04:41:40 -0500 Received: by mail-ed1-f67.google.com with SMTP id b3so7516301ede.1 for ; Sat, 02 Feb 2019 01:41:39 -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; bh=iULYkK79KzQBLjCzo7CPIeChw9PmIPBpwpuo29dYAvY=; b=T3vgkLIZXa0V+j0poP/GqVK5uMWVYHB5KT1wpcxU8+sWPsMPj3VSoA1cLPuqgiTIvK DFPkzouQE0soyhlw+bXv8OqICmb76KmSNL4cxWJBi0UeaOV1fjBHdcbQWQZImYVfwwlv 4WniOgtSiPG/V0nai9ug659D5v2uzCMlRc0A4= 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=iULYkK79KzQBLjCzo7CPIeChw9PmIPBpwpuo29dYAvY=; b=IJ8vtVmo3iMuAE5Y/jQPKrI6NycQ/NT+kb+p0Dc1vYseoH72vvMUinb/bPu0auEKJo VLGNDsvf/s6Ld8U7U7Eu1Waecbo8u0fDBAON6n2NUjJlPVeE15HH/h+rN6T2IHVWhFc/ sFSfEYHQXO2GVPi4QnaSvvZHDntir4GIvlr0fVMB2roJw6uIOnMGo3VvhHVRXZD2Wy+F egPTAg89yj8UpBAhVclAYAAk/FrYt6qUB8q7MZbTA39RTRXqBBlch4/vJrTpQbDl55Gr ZaEqlx08qsAKMe+wLIlK6xLhg9eR+YC15gzQ+pV5XePPnVcfHmEdC49Y++FUxQOY+d+N HH4w== X-Gm-Message-State: AJcUukcumAvlsxJbAGhZm46swnUVNhGyGb8UowcdPNmMP6LSZZooiN17 5QjVVZzQzCZ6hEcXNyFUudjG9A== X-Received: by 2002:a50:9b1d:: with SMTP id o29mr40373314edi.246.1549100498944; Sat, 02 Feb 2019 01:41:38 -0800 (PST) Received: from mba13.c.hoisthospitality.com ([109.236.135.164]) by smtp.gmail.com with ESMTPSA id l41sm2608824eda.83.2019.02.02.01.41.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 01:41:38 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, AKASHI Takahiro , Alexander Graf , Bjorn Andersson , Borislav Petkov , Heinrich Schuchardt , Jeffrey Hugo , Lee Jones , Leif Lindholm , Linus Torvalds , Peter Jones , Peter Zijlstra , Sai Praneeth Prakhya Subject: [PATCH 08/10] x86: make ARCH_USE_MEMREMAP_PROT a generic Kconfig symbol Date: Sat, 2 Feb 2019 10:41:17 +0100 Message-Id: <20190202094119.13230-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190202094119.13230-1-ard.biesheuvel@linaro.org> References: <20190202094119.13230-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Note that the encryption related early memremap routines in arch/x86/mm/ioremap.c cannot be built for 32-bit x86 without triggering 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.17.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;