From patchwork Fri Jul 26 23:51:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13743512 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 C659FC3DA4A for ; Sat, 27 Jul 2024 00:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=khS3+Cji6+1mvvdZyBUq0wqzq89EmN0cfXvMph1EjiU=; b=yNpuyvfSUTUktRiUikootO/HHj b2ZzgMmLsyU2+9XuNx/U7SaM2F0Hbh/3B/4ByjX2K6Jy8vwbhLa0i0UBYFmoiVHJr92J2c22NVXjY jEqRbCDVirCWziev7PMdtz20Ou0Rx5IAb82oY2wxwXK/Jp2wnhQlCeB82QwjfNYrTH/98m4eiqHCG vh7ec9cMhTPZlHvMtvi7SEdzqNCpNdu4gWYASvGZldsG5GD1Rf09E1KoNG0oMdZcnx7bq0OUK5o5s w/8wyvhSTbo1HnY6jSSKwKC/ihWFlao1LMcnO7VgHoS3rJ4FM+YasMCmRt9VB4n0KLpeye47OhFhu Ds1BJa8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXV5l-00000005bRp-04tw; Sat, 27 Jul 2024 00:15:21 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUkT-00000005Pgl-3Znq for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:53:24 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-66619cb2d3eso5958507b3.2 for ; Fri, 26 Jul 2024 16:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038000; x=1722642800; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=khS3+Cji6+1mvvdZyBUq0wqzq89EmN0cfXvMph1EjiU=; b=KvxIQGnXip473lLe0HoToInPHj5B3ZtL3zx5YTJiKrbCyzIxwLoAFRRWRAPESmPsLr Ic4RmzryO37taIULCvQrT77myehCiDqNH4UN/mpNXb3+4A/WfPsPJNSIGX7AZJ+/0oZX xbjm9CV8ZKtaG8XG4gBxuFbw7yFy9uyAJ1iL03MlwUwMFMslPIdfOrY9/UMwuZ/su+JZ ZkDtdP9Y4xtiuOC103tVxcrBbRXz1Sp+iaxo/2HO7WIigITw08/xqQmXazu7AT+bzBZW 7PqI1BLLTnVL+Q82qzaj2gpgR2D9bLfIKD7N+wYLPn1mbwT4hVt35j0l8CvBpmCzjGDI 4pxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038000; x=1722642800; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=khS3+Cji6+1mvvdZyBUq0wqzq89EmN0cfXvMph1EjiU=; b=TJGu36pmSv0ZAMml5pXPAqeVLD60aqXSohPoRLJ2HKHfkj2mTLt7/HnN7ala9+006C APrzNnthqLftIenNp2j3bQ5t0O0h5M041h7393rQ4q47RG8+TRRu7agbsGRIpfXfoOQY tSNjtsX85kFt1I0uNQ5te+nxxkCj8Cl/b0caJI0H7JAw9teL55uLqayIZ8moKkdBOmvW 8stwq125Vd9HWRk+qSCe5ugcchGcwGaf8cqAfYi4qZLyRVQZQb1Zi9EcgCvBFBlFwNPK M+ewuKb6WbpcG4fD2xDhelgyQw4QRbPhzeJwUiUuFP83dEnM6gvwnkKLhIgMUw+HQhYr JdSQ== X-Forwarded-Encrypted: i=1; AJvYcCWRS7zXJa2Yys5jvbYueJeD1dHw2lXPvrMSByGVfAVbztnfDtN5oU/Vhb01TcUtRS9tBi1kAyAeyTHmUN9icMB2Yly8G75u989YhzcSMv6aUEHMVRk= X-Gm-Message-State: AOJu0YzPROafxtz6I/oqbnqc1YT/AMSq4Wofig9CnJqzKv2NOjvs3BMj oMLDrJj4kcldaGix59TiHUR17oP9lNoDp8ooCp7SZRSPMQoTn4tub5LlSZE58uWBvog0oUHOQJs HhQ== X-Google-Smtp-Source: AGHT+IHn8ljNba0QNoBWKfaXu8Wx8VTGIoZ1RPeW8pDsltrF/Hl6Iy7/rU4VvDeHaG7eZvfgbbZBLlqPjFc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:806:b0:64a:8aec:617c with SMTP id 00721157ae682-679fffd3e35mr362617b3.0.1722038000511; Fri, 26 Jul 2024 16:53:20 -0700 (PDT) Date: Fri, 26 Jul 2024 16:51:30 -0700 In-Reply-To: <20240726235234.228822-1-seanjc@google.com> Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240726235234.228822-22-seanjc@google.com> Subject: [PATCH v12 21/84] KVM: nVMX: Rely on kvm_vcpu_unmap() to track validity of eVMCS mapping From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , David Stevens X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_165322_011737_9180DE2C X-CRM114-Status: GOOD ( 11.62 ) 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: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove the explicit evmptr12 validity check when deciding whether or not to unmap the eVMCS pointer, and instead rely on kvm_vcpu_unmap() to play nice with a NULL map->hva, i.e. to do nothing if the map is invalid. Note, vmx->nested.hv_evmcs_map is zero-allocated along with the rest of vcpu_vmx, i.e. the map starts out invalid/NULL. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 2392a7ef254d..a34b49ea64b5 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -231,11 +231,8 @@ static inline void nested_release_evmcs(struct kvm_vcpu *vcpu) struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); struct vcpu_vmx *vmx = to_vmx(vcpu); - if (nested_vmx_is_evmptr12_valid(vmx)) { - kvm_vcpu_unmap(vcpu, &vmx->nested.hv_evmcs_map, true); - vmx->nested.hv_evmcs = NULL; - } - + kvm_vcpu_unmap(vcpu, &vmx->nested.hv_evmcs_map, true); + vmx->nested.hv_evmcs = NULL; vmx->nested.hv_evmcs_vmptr = EVMPTR_INVALID; if (hv_vcpu) {