Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2292431pxb; Mon, 18 Jan 2021 13:43:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzJQtwzgCEpFBfaERjatANi7nd1HPHwwdTotMClZ0kRia9veROz5fFOKOo0j9HIHkzutIw X-Received: by 2002:a17:906:7253:: with SMTP id n19mr1026020ejk.543.1611006225142; Mon, 18 Jan 2021 13:43:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611006225; cv=none; d=google.com; s=arc-20160816; b=xwCjPLVwvem2lO9WsFmrOHI9aV981GsAtuMFUBquv6SZqA4RXVvkjO8o4hctPmKgR/ uU7o3TwOZwykKgJZTR8ZpypbhivbN66yt+Q1VSbhRmHSv80aGyMQHv1pCgXoD87K4u/O NdHl0HY2igX+LzGUXEyb1TnkvoJmJ7WzQ2/xW/+ErGZlDsEULCe/aN/EHOYWxH+2FRSh 9X84/z+PES0kwdiDOhz0c0je0Hsn9KuXoDAKJxZI6ySAwkRDa8Dw/iSF7JHHgNPGX+/b pHYwCyM+j4jwnUpIen9Nx4Tht6N2VE9BODPJv4W9NnKTkYm/Vu9SHpQAfgoJjEA8sils dnFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SVkIW7rC0KFoQJkrM7XbydMbkl12yVoSEIsOPH1u2Dc=; b=bCLRsdN5npXmWYyGzv/kMU2zhqrCj4ER2wyz0eSja017+V0DZ+i9kWhoDyDOHaZ0bo WRSxLrDcgwEvL69u9cS6ktdqPJWw8P9sd/TJxOGCpxwHW7x33HwZAfBV4vrh2p0cAXaC A39friXCnteOqhv9o4eZ5vbKyDlpUiHGLVZKnsYmvt+tjz/fNhLJQrlshht5ewmlpwLN hiq3mHDxyR29tAJ/No6G8bqke47+kC2BK4zS+JclUTkYU1vDzD190Nsh9OrqXDnisr4/ 2PXxHzjxflsAus9FoMNFox+BIWMFz7APkuh4+oTM/AVIJ5AsJN2PncUItwQ+g2eaiKYO Rb6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si8427840ejd.325.2021.01.18.13.43.10; Mon, 18 Jan 2021 13:43:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394870AbhARVkh (ORCPT + 99 others); Mon, 18 Jan 2021 16:40:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:38498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389070AbhARKAu (ORCPT ); Mon, 18 Jan 2021 05:00:50 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ADA53221FF; Mon, 18 Jan 2021 10:00:07 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1l1R6y-008RhD-61; Mon, 18 Jan 2021 09:46:12 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , David Brazdil , Alexandru Elisei , Ard Biesheuvel , Jing Zhang , Ajay Patil , Prasad Sodagudi , Srinivas Ramana , James Morse , Julien Thierry , Suzuki K Poulose , kernel-team@android.com Subject: [PATCH v4 16/21] arm64: Make kvm-arm.mode={nvhe,protected} an alias of id_aa64mmfr1.vh=0 Date: Mon, 18 Jan 2021 09:45:28 +0000 Message-Id: <20210118094533.2874082-17-maz@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118094533.2874082-1-maz@kernel.org> References: <20210118094533.2874082-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, alexandru.elisei@arm.com, ardb@kernel.org, jingzhangos@google.com, pajay@qti.qualcomm.com, psodagud@codeaurora.org, sramana@codeaurora.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Admitedly, passing id_aa64mmfr1.vh=0 on the command-line isn't that easy to understand, and it is likely that users would much prefer write "kvm-arm.mode=nvhe", or "...=protected". So here you go. This has the added advantage that we can now always honor the "kvm-arm.mode=protected" option, even when booting on a VHE system. Signed-off-by: Marc Zyngier --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/arm64/kernel/idreg-override.c | 2 ++ arch/arm64/kvm/arm.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 9e3cdb271d06..2786fd39a047 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2257,6 +2257,9 @@ kvm-arm.mode= [KVM,ARM] Select one of KVM/arm64's modes of operation. + nvhe: Standard nVHE-based mode, without support for + protected guests. + protected: nVHE-based mode with support for guests whose state is kept private from the host. Not valid if the kernel is running in EL2. diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 16bc8b3b93ae..1db54878b2c4 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -41,6 +41,8 @@ static const struct { const char * const alias; const char * const feature; } aliases[] __initdata = { + { "kvm-arm.mode=nvhe", "id_aa64mmfr1.vh=0" }, + { "kvm-arm.mode=protected", "id_aa64mmfr1.vh=0" }, }; static int __init find_field(const char *cmdline, const struct reg_desc *reg, diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 04c44853b103..597565a65ca2 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1966,6 +1966,9 @@ static int __init early_kvm_mode_cfg(char *arg) return 0; } + if (strcmp(arg, "nvhe") == 0 && !WARN_ON(is_kernel_in_hyp_mode())) + return 0; + return -EINVAL; } early_param("kvm-arm.mode", early_kvm_mode_cfg); -- 2.29.2