Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp15733lql; Fri, 12 Apr 2024 02:02:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVxUYQtm/6bRp9qSa/SPHBthVweA9JZnSsRDd8z+VNnuJ2v8Vhr6DaWIRdjs2wrgI75vXNAs0pKcwjpRGQxwTUCj5hewGSVRUdoY8VbA== X-Google-Smtp-Source: AGHT+IEV0aGMb/zcCyIsJtnZQgcVHpU+rRN9wMsCzU47/eN/ovL5M6/iaoNQxyFJ1JlNylKr81fk X-Received: by 2002:a05:6a21:7899:b0:1a8:4276:670c with SMTP id bf25-20020a056a21789900b001a84276670cmr2673413pzc.17.1712912543716; Fri, 12 Apr 2024 02:02:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712912543; cv=pass; d=google.com; s=arc-20160816; b=x2w38Sd87cU6WHhRx6tEXEQaleJI1oV0JQBNjThA16S+FWa9JVhZa2yLJmUOMJTY96 lc4EYYY8rMRQzsoWeTfTZtBlrBiPmcX+AI5vVm1X1FxQ0VOWI9u7WaFlEDY6BhCWSGJT Rmk3tTkDLg2/braUl4AU/oFP9X9OdDWnv5+/JCli1bGoV0JNoL4RTHAYI3Eou+IEjhnZ Wa195/T8LK8x4twes0xReBqlRrEeqSbC/9oYr4yqNk/xTnQ1fQsBX8ZuHa61fIEthpCL k5BduQjRXHciBD6xL2NiqGnkKxyr54kM6hXWL41rW9fq48C5hcVUvAJM4qGep1ss0cRt 5xfw== 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=x0KBbddmBhn2vVd+V1CBcTDZpzAWHb2aeGnU/OfFbyY=; fh=NDCPdPn2hiqHaiIRDYQAzsW9PK20CTia4nECGof6enU=; b=RTzVYbn7MiFBhMDTO5XMfIOwN7vgEkM0xvSZxvVhnDhkBlMJ6cZLd8ocURW+qjyi5R 6OA431qm+ZMkKzIVA1YOUWT2DXUQAvJJbbVasFGPPI7p0/BE6A4XK9FL9qFbi7rGBIZW 5F9k/YLKhkRF4Uo2fN2EMl0T4KFUBS+PGW9CSjWe+rKqmmkM6WNmVmtKsy+mXW8JnVr+ ltend+Nflb6YoZKITTJvZqCu7Aronl5Zu1bbs+eJIuuXL+LlNHwnOwf20QiCLJ+nSCGu Ah4qNAtkaWUC08duWN/hulthaXMnuljADxMIZ0OnFyspUQ6m8F8XC5akbO4TCe4lT1vD fTLg==; 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-142292-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f14-20020a63de0e000000b005dc85e8a9e1si2825202pgg.45.2024.04.12.02.02.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 02:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142292-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-142292-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142292-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B52CF288A8D for ; Fri, 12 Apr 2024 08:55:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13E6C84A5B; Fri, 12 Apr 2024 08:44:12 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6090A84A32; Fri, 12 Apr 2024 08:44:10 +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=1712911451; cv=none; b=kIxg9u7BPK1KDHCqLiGZvx8nWv26M+bWB6MqjyqTDfT8ZLMyFo5UazTj6mzOHLFP3EDOLzZiSXBt0DT3+xXOOLpkQmpB7EZqFopx8/pjPr6WRZIj8mmnPiiSAsxc2VpV8t9rI+dWZSrt1/4aXtOTx3K7Udz+XVOARCXLDK2+JDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911451; c=relaxed/simple; bh=+/EYSelihAXpErospJh6KWpMk2w0Em/EAZY6R3tdOlw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fzZbGOLfqLuEEb3EETrGcJhAqYHsSUTICipHbew5/YAYt76bmfyg9VlNn3k8PCLMtYeTYcXUWDL33ctvHlOw6mhLa5F10swFpTyXH6Ze8iJGU0ERRwnjmM7NtS1NqPmKqmeFq0l5b1SroQKihqWDUS4Lb60HcMEnh9Otjr7vix0= 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 54FCF113E; Fri, 12 Apr 2024 01:44:39 -0700 (PDT) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ED2313F6C4; Fri, 12 Apr 2024 01:44:07 -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 v2 22/43] KVM: arm64: Handle realm VCPU load Date: Fri, 12 Apr 2024 09:42:48 +0100 Message-Id: <20240412084309.1733783-23-steven.price@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412084309.1733783-1-steven.price@arm.com> References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084309.1733783-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 e92afb3835f6..4fd58a1d3351 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -512,10 +512,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); @@ -524,6 +520,15 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) else vcpu_set_wfx_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); + if (vcpu_has_ptrauth(vcpu)) vcpu_ptrauth_disable(vcpu); kvm_arch_vcpu_load_debug_state_flags(vcpu); -- 2.34.1