From patchwork Fri Jan 27 11:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1514CC38142 for ; Fri, 27 Jan 2023 12:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7f+K4VsJWFkALEAItc+sm1QIJ3h6EYhJOyHIm8x8Bec=; b=se2s53Hs+sgYfo AVB7V9lKCqI5l5QbGkZ+0PXlWfNjtkOcRtGyvSXyySCy3G+ThUAkOZzkZpeRAYeOXdxF4AF3PL60j x/cS6bF7M3hSaahUx7kSmwm1it2T+NUZZe0kBBHiB4T17BBzmcMliqvPtvnoDrnNO7ZJtgdL3j5DD MeG3Ur++RpYXSGQYhOwABtQ1w5KDGnuPUlIKDdvgXumLYKU3t9O90mA4r1O/Ah9zw+DHAnJVWsGf7 Rc3f5dcDw+YotJB7ltBo/0eEuK1+sPW0IV75EiOHUTk29oTOFgZtTAFgaCMD2bQ6D1g3SLqRLq9Fh K16inS+3sJ0/TegKbYmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNQg-00EMns-QL; Fri, 27 Jan 2023 12:02:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5V-00ECoJ-Ox for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D42961688; Fri, 27 Jan 2023 03:40:50 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 56CDA3F64C; Fri, 27 Jan 2023 03:40:06 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 07/31] arm64: Add option to disable SVE Date: Fri, 27 Jan 2023 11:39:08 +0000 Message-Id: <20230127113932.166089-8-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034010_016246_F38BF476 X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org kvmtool enables SVE whenever it is supported by the KVM. However, Realm VMs may want controlled features, which gets measured during the creation. Thus, provide an option to disable the SVE, to preserve the current behavior of SVE on by default. Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 4 +++- arm/aarch64/kvm-cpu.c | 8 +++++--- arm/include/arm-common/kvm-config-arch.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index eae8080d..b055fef4 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -19,7 +19,9 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); "Specify random seed for Kernel Address Space " \ "Layout Randomization (KASLR)"), \ OPT_BOOLEAN('\0', "no-pvtime", &(cfg)->no_pvtime, "Disable" \ - " stolen time"), + " stolen time"), \ + OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ + "Disable SVE"), #include "arm-common/kvm-config-arch.h" #endif /* KVM__KVM_CONFIG_ARCH_H */ diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index da809806..e7649239 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -149,8 +149,9 @@ void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC; } - /* Enable SVE if available */ - if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) + /* If SVE is not disabled explicitly, enable if available */ + if (!kvm->cfg.arch.disable_sve && + kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) init->features[0] |= 1UL << KVM_ARM_VCPU_SVE; } @@ -158,7 +159,8 @@ int kvm_cpu__configure_features(struct kvm_cpu *vcpu) { struct kvm *kvm = vcpu->kvm; - if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) { + if (!kvm->cfg.arch.disable_sve && + kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) { int feature = KVM_ARM_VCPU_SVE; if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) { diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 9949bfe4..6599305b 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -15,6 +15,7 @@ struct kvm_config_arch { enum irqchip_type irqchip; u64 fw_addr; bool no_pvtime; + bool disable_sve; }; int irqchip_parser(const struct option *opt, const char *arg, int unset);