Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp376930lqp; Mon, 10 Jun 2024 06:58:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmV5TsNtIw4OnWuq/wrDRFgou5nr+9hNXFOs4p2tObOs5GtEi95VEAzaR77ktPner7ny2Wh5tWm98cxOPVNlMOtYBvmAZcQuQ2wCdXgw== X-Google-Smtp-Source: AGHT+IH3MEKpIZF0+B4lAWnqPL8WK867sj/Jqm6SqAlg+kGSYeL9kbTkEP6cU+BMLc1HofCzU1nk X-Received: by 2002:a05:6e02:1a4c:b0:375:9cb9:9cff with SMTP id e9e14a558f8ab-3759cb9a12dmr56143265ab.7.1718027893301; Mon, 10 Jun 2024 06:58:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718027893; cv=pass; d=google.com; s=arc-20160816; b=OsO2G1QVYH5CywLRt11mpStwJmlpsRooZpvP/IcFj7RjDMxMwe0E2u+OV/G8dwQ78a 3vbIbw+F0U/NddzeNN7TjldZeObl9FaoTpHjZfQCJsXeMXlGd8Z+fQ304kXBpi3IxJCN 3D5RqfwCKvuuTt9zxw3i0xKniTavGTL8wC908fW3ffu/O0UWkiRkHK5w6wwDoOkd62T5 u4pZhBE7VZjMrFzfEc5nXBV1Q9d+ZuZL85WUR/j13r50XUMduSKzFsPlea39shfwq64/ QivA6IoCrhHz5QkjM+nM8vSF6cC10W4mpWFdZjpE39H/GbVmjbiIOsASjzhJAboZBYSC DvrQ== 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=xDzLJWgIf7QdzuuE0tXEWlsfvMNIPnnAJoRZZ4qD1gw=; fh=NDCPdPn2hiqHaiIRDYQAzsW9PK20CTia4nECGof6enU=; b=qAkVS7Oqj+dVYL26g72WPjwMjJ4hTquvItBfpGt4Sx4JpBnKgbaQIAiQOhwo3PzCvF ZdX4ziGe6Y3HMB4aH7MgwOKHrtxRbyWQXj2n9RerWSH9u/GCkIBy9SzNtIfrHuTqsUc7 Xlnw2MLeMWWaDUfguZZoUF15tupVANZ8ooyMhta0JwRGbHwqRbD2jr3WCDDqu7Sx7ILx tkaF34/bRI7Ss5R/9icWWKvaD3bnxdAH0tDrkK4Kf6GHVgHMGwqn89kw/1304+f9ra2w C8nURt6Et7yqmbrUIDFettCVca3HHK2qbgM7YIy3A+HZWucYTSyCi3z8I1UnqZQL0iTX 1sng==; 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-208269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e62bcfe5besi4726602a12.17.2024.06.10.06.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 06:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-208269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208269-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EDD10B248E6 for ; Mon, 10 Jun 2024 13:49:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D43D1534E6; Mon, 10 Jun 2024 13:43:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0B251527B6; Mon, 10 Jun 2024 13:43:30 +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=1718027012; cv=none; b=ezoTiHBH++xLluko1T0knKh+VGy3uIidXZ1gIJtroWtRDlI8NUoU5afyhhpj3l51Ktfbe3NbssAjrCj6H6/ZaaUgg5TJfIcwcZHd27IP7nAsGsbPW6cxIzLeasH+s5yvBqwviA9IzykoNkfPbKUCdYecGXjTGSF+tHfgUVrxi6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718027012; c=relaxed/simple; bh=QUl/u0z1+bUgdg7xqFp5aPUhen946YdMdodFhv62kWU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X7enVktpq+ZZ6CwO5RFFeE3Gg0XnmQZB1lGjy/sTnCX74vQHGT6wMdK8DmpWBetdc7QNB+0ZVWHVmANmS4cnNIpGWlnylPB3moKLNHE/HkkYOdklIm4RpdXSLnP3FjcmwCwEE59qR2oBzLSoh6IgXQHMfnr5lTZPNEspha/Ht1c= 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 EFD5D1692; Mon, 10 Jun 2024 06:43:54 -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 C7BD53F58B; Mon, 10 Jun 2024 06:43:27 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Steven Price , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , 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 Subject: [PATCH v3 22/43] KVM: arm64: Handle realm VCPU load Date: Mon, 10 Jun 2024 14:41:41 +0100 Message-Id: <20240610134202.54893-23-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 When loading a realm VCPU much of the work is handled by the RMM so only some of the actions are required. Rearrange kvm_arch_vcpu_load() slightly so we can bail out early for a realm guest. Signed-off-by: Steven Price --- arch/arm64/kvm/arm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 0b51ea30d679..aa57aa8cab4e 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -630,10 +630,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) kvm_vgic_load(vcpu); kvm_timer_vcpu_load(vcpu); - if (has_vhe()) - kvm_vcpu_load_vhe(vcpu); - kvm_arch_vcpu_load_fp(vcpu); - kvm_vcpu_pmu_restore_guest(vcpu); if (kvm_arm_is_pvtime_enabled(&vcpu->arch)) kvm_make_request(KVM_REQ_RECORD_STEAL, vcpu); @@ -644,6 +640,15 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) vcpu_set_pauth_traps(vcpu); + /* No additional state needs to be loaded on Realmed VMs */ + if (vcpu_is_rec(vcpu)) + return; + + if (has_vhe()) + kvm_vcpu_load_vhe(vcpu); + kvm_arch_vcpu_load_fp(vcpu); + kvm_vcpu_pmu_restore_guest(vcpu); + kvm_arch_vcpu_load_debug_state_flags(vcpu); if (!cpumask_test_cpu(cpu, vcpu->kvm->arch.supported_cpus)) -- 2.34.1