Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp373095lqp; Mon, 10 Jun 2024 06:51:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWujOWn60AkH5vL1v7yn4uBtNcQdEL46jxevnFBx3SZkwIYQbNr7aga2nvd8ogbHZqdca5spOBBaVrIMJjIRxxuC+ef70Tgi1v0/7pJpw== X-Google-Smtp-Source: AGHT+IFAHWLppiOA8/49JbKQ5xvMvSNe0mD62Rm7LeONBPetwXebxJX9C3e3BOYwZSbBBmL2Hw0m X-Received: by 2002:a17:907:31cd:b0:a62:edcd:87c1 with SMTP id a640c23a62f3a-a6cd560f947mr882143966b.10.1718027493979; Mon, 10 Jun 2024 06:51:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718027493; cv=pass; d=google.com; s=arc-20160816; b=B01B+2DrW2pldf7D/oUMwB6a+zo16WkhM6nE6sjmBEIFW2ogZHFKEZmseoz9jXFegM JifLjEf8WfEYGyXzKXQmwVUpRSJ6V1A8fCRo46CX9bHQrEeYu5jPaoM6cRV+pRyoUTmX VefR4blKliDafg0Sk4/QcGMdSkT1OPfdRNYSIOXUzyEj9vX81Yr3FX2j6v8vwLKTIvPe H0egM0O//UurNzfSSM4/dRaH86gPVZGcw1SsUf952/skL8CgxEykm8l6eY/ZX5EqxBbB 8CyjQgAGjRZVjpXbJ0uUIjouJQiZuCP7HcHQFLJrlSHF8/ziy1LmYlrFBM+57KZidkQy 5KwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=w9qF3T4FcE7Zb3c4WZn48R9PJoLaqiSg62bmVl7YPlo=; fh=mU6xl5FN63PgqIKyLHx/u5uRervM0V89cYoVjXl22Bs=; b=BBlxCL5+a5JS7Irx/UC6TfzQC9UcftCdWquOidC6X/1ARUa5IAJIc7aJElswZkYoCW FhPcdYhwIeEo2jlA9RlCtru5ezg9EARJ+i+c3zdXJZ4g9UHuZcupWfl9yYIgaDjhRDwM 4K4jM6Jvcz1Z2E5IFuvlAiGj8I40LL+CaLcs4XygZl+RRX/HjcM7B5RX5uzmBVZCH2iH 0Racql2E5GGx2Cl6pOuSRMFueSDHih8LF9wooW9ZkMUcJOt3e1AntMbnSZSG8M290fhE mCTc6xk/bpw7x3EE2phDkGEF5N37zvtPjAz/zu6zID/TkBYgK2MDJd8SkrHrHXvdP5VQ 124Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f2f12e860si21828166b.564.2024.06.10.06.51.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 06:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AC4231F23A66 for ; Mon, 10 Jun 2024 13:51:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD8DC7CF18; Mon, 10 Jun 2024 13:43:58 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFC0B155CAD; Mon, 10 Jun 2024 13:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718027038; cv=none; b=K0WwOBG7651NZTdDn1VmiMeeuI9lJ5BxVcf0tPa7bun9vPljgMjXdJi8yz+7kioq0ySUbQth/s6WJODyDeYVJxRfmP4HyzXVyJLGz4bNRoGWfFR986Mc93r7LlmGDlNOnJ6bh4RzR2itPxNTHAdhNpWRqJL+OdJ8a1ZKJIm0aD4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718027038; c=relaxed/simple; bh=JakuwZyfWuRj+LSBmL8JujU2hcmbalbe1ijSmNNhEVE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a1TMC1zOIK4614sPk3KkuzfYGcFEQrgJZyLglBb8U+i5LpaYkXM6W15sCmrgyk6WMF+oiOzYRL/eveX7EgOD3yUYdMh4td7+qgVLT9QhvikWo7ky22YiN5QVPZKUwRK5iXlJfDOU9mjI6tk2qQDrIsT7bRzhuJxjY1IruekN/ak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 19E5F169C; Mon, 10 Jun 2024 06:44:20 -0700 (PDT) Received: from e122027.cambridge.arm.com (e122027.cambridge.arm.com [10.1.35.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E0BCE3F58B; Mon, 10 Jun 2024 06:43:52 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Steven Price Subject: [PATCH v3 29/43] arm64: rme: Allow checking SVE on VM instance Date: Mon, 10 Jun 2024 14:41:48 +0100 Message-Id: <20240610134202.54893-30-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610134202.54893-1-steven.price@arm.com> References: <20240610134202.54893-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Suzuki K Poulose Given we have different types of VMs supported, check the support for SVE for the given instance of the VM to accurately report the status. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price --- arch/arm64/include/asm/kvm_rme.h | 2 ++ arch/arm64/kvm/arm.c | 5 ++++- arch/arm64/kvm/rme.c | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_rme.h b/arch/arm64/include/asm/kvm_rme.h index 5492e60aa8de..80c7db964079 100644 --- a/arch/arm64/include/asm/kvm_rme.h +++ b/arch/arm64/include/asm/kvm_rme.h @@ -89,6 +89,8 @@ struct realm_rec { void kvm_init_rme(void); u32 kvm_realm_ipa_limit(void); +bool kvm_rme_supports_sve(void); + int kvm_realm_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap); int kvm_init_realm_vm(struct kvm *kvm); void kvm_destroy_realm(struct kvm *kvm); diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index f78e92dfaa72..f3743ba8b006 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -442,7 +442,10 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) r = get_kvm_ipa_limit(); break; case KVM_CAP_ARM_SVE: - r = system_supports_sve(); + if (kvm && kvm_is_realm(kvm)) + r = kvm_rme_supports_sve(); + else + r = system_supports_sve(); break; case KVM_CAP_ARM_PTRAUTH_ADDRESS: case KVM_CAP_ARM_PTRAUTH_GENERIC: diff --git a/arch/arm64/kvm/rme.c b/arch/arm64/kvm/rme.c index 45d49d12a34c..999bd4bf2d73 100644 --- a/arch/arm64/kvm/rme.c +++ b/arch/arm64/kvm/rme.c @@ -20,6 +20,11 @@ static bool rme_supports(unsigned long feature) return !!u64_get_bits(rmm_feat_reg0, feature); } +bool kvm_rme_supports_sve(void) +{ + return rme_supports(RMI_FEATURE_REGISTER_0_SVE_EN); +} + static int rmi_check_version(void) { struct arm_smccc_res res; -- 2.34.1