Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3880453pxb; Mon, 8 Feb 2021 02:27:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2UDR4c/9HlymXPrKbBg6XN2uEwlpvtJXOlr51CyaR/cVXso/byR7TNyXdYQklIrHH9rnH X-Received: by 2002:a17:906:6087:: with SMTP id t7mr16510750ejj.90.1612780032644; Mon, 08 Feb 2021 02:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612780032; cv=none; d=google.com; s=arc-20160816; b=eKCJAA8eh/Wb0znuPrODaVN4Xx7aMWCEt1EuEd4RhuagdvRFQzsRGPiZO/UN8rdTnm z5FiyZL43x28hec1M737+Kvd6uf4/rgRptQAFcRGay2PLAtxy6FAHoOgVUmIiUtj6HQZ JJ3nYjQs9HXj+A2cT/EdVeCfy6uVzXO1ZRuXXdTS9f1qTxWK2dwJgmOEbJZUOrnL7jyl dlO66/Z4AanjuuL5mOYZ8rfNQ6+81sVZqh2zr1Qkl8EbYCfSIHCMTl7luLyKoHebUc8H k9AlCAkDmBGFqsOmQyhyzpiJuVcsQZ8Th0/MkxjYWE3EuobelRA0DSDEJrvj5fRQOiyz rZZg== 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=jlOXDIack6dmqGk9wUI8GXDLUMF9J7tT9sp5stzL+hk=; b=TUT6/PRErBTAvA0+s2lCZMzEn9mFdw4yXHRcPGqpHLhUztkBTr/26/965S9Edil3ZW NUITU0UHJnQNtcQ3XwaDXRTv8+s2TuMVAi9biBdaykDg5Nk8vQq50ThlPHmXweDDnuKo xU5UPZY/VoWk2JKqvdU8Uq2anq23naCPZXxzaHXNh4+fkb4n1Nh1kOykvMRHWJyIZPJr jzfCOjFUgifW4tkmPKYIIPo7C8SC6o0z5mhtVbbR0dpwaXJryKgHsh3Q/N37hQ9YiL97 DBgqgKd5hnum5FtdX5BBGeOZ6HCKphA+6r3ovaeo3bpEt1E6YETgCSuKAPJrRnmCWWMb o+Fw== 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 lv10si11635490ejb.505.2021.02.08.02.26.49; Mon, 08 Feb 2021 02:27:12 -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 S232158AbhBHKXj (ORCPT + 99 others); Mon, 8 Feb 2021 05:23:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:33020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbhBHKHo (ORCPT ); Mon, 8 Feb 2021 05:07:44 -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 EDC2C64EA6; Mon, 8 Feb 2021 10:04:35 +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 1l93J1-00Ck14-AD; Mon, 08 Feb 2021 09:58:08 +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 , Hector Martin , James Morse , Julien Thierry , Suzuki K Poulose , kernel-team@android.com Subject: [PATCH v7 17/23] arm64: Make kvm-arm.mode={nvhe, protected} an alias of id_aa64mmfr1.vh=0 Date: Mon, 8 Feb 2021 09:57:26 +0000 Message-Id: <20210208095732.3267263-18-maz@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210208095732.3267263-1-maz@kernel.org> References: <20210208095732.3267263-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, marcan@marcan.st, 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 Acked-by: Catalin Marinas Acked-by: David Brazdil --- 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 226bac544e20..b994d689d6fb 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -45,6 +45,8 @@ static const struct { char alias[FTR_ALIAS_NAME_LEN]; char feature[FTR_ALIAS_OPTION_LEN]; } aliases[] __initconst = { + { "kvm-arm.mode=nvhe", "id_aa64mmfr1.vh=0" }, + { "kvm-arm.mode=protected", "id_aa64mmfr1.vh=0" }, }; static int __init find_field(const char *cmdline, 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