From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4280515958E for ; Fri, 17 May 2024 17:41:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967675; cv=none; b=IxmZU0VR+CQ5yzsooc48sXg21LT+CwCi1P/tUzLiF1A7WfTIheE9PcRAZLGTE7Rx1Vv6PUV0Nwc3HA8ioylvXS/69pQBjSeGRtBnAv2Vmn6gf8XfymTVrBMZRdKKbDczTvX705RqNx6gan47bkfVFMibpPgz2NdCYmprDv0fdgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967675; c=relaxed/simple; bh=DbRs/X4W9CfO4QMBHQGwEV70PLWdGInmhoZ6jcJx+o4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Mq84yja1xQw7RcvSlzmeapLMhwrxogNaesdgCO4D33gKHXCcZEsGKmh9XXx0aLmjED7MCFBOpHPOuoSKgfw8wfLJo/ffnkytguICm9XJQ2SlZdYEVC6lD8Ns2gGLsYt6p4Zar710B/wiXUykUbvDQy3scDsEH6hT0SKlJmM1KdQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cneBLwrI; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cneBLwrI" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6ef9edf9910so10631894b3a.1 for ; Fri, 17 May 2024 10:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967673; x=1716572473; darn=vger.kernel.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=tJWRXOUZEf0tFhXUEsVYsHdLmAwURDTHhDYt6uCUFks=; b=cneBLwrIX/09t74mq/vj2oGl7EdY6CzBbaoPFAs6EyDOq0tf/X1PUqqUwEEKxr/3o2 KGfNb4TO37BhPeXQ+pNImpudUN5fjj7hLYkrt5mnHXk2Z61tZRC9aXmtZ2X2yiq51GFI w5aE9i7IU31qVorTn6XJ7xsrTvsS6FHA6Ayb0oKMsefVWkEmA9dbNfGHr85gy97CsBYF tX35ayncrgUWAxodsLaLDGet3KoidumE1f/t2dlWSJY2EnbCBCNYcK4DTd/zh+vtzF/r uHyMDwTBgO59jL0tXKEtyjCE9XZi/40W+6/G9nyf+0JyHbboqsFEsRkNobKtWgD8TYyO gwdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967673; x=1716572473; 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=tJWRXOUZEf0tFhXUEsVYsHdLmAwURDTHhDYt6uCUFks=; b=mZx3pI+RXDkgTMDK1RGTpSXVPmWJsDrkgNcd9ZyiWuoPRRUBud+2QaZzDvKneHMZC4 mEnB8An5fw2dCMck1o9uNFuXR2yQUvyF63Jzp4aJMD37KEWBQ7XWf4QeM6OOGJNpS67t W8H+jsK7mr0/9mJOoebwWbp8VKx/ftYZS2jFe4ITd6y764xM9GgdNHqM8SCQehvJoJBb 8Ewnk0W5Dd+hd7VsuqcJ+URAGL0zplYvuyAbuT4EtDG+QqVZUQE41/gcRACaLuhmcvD5 sPKexKDwj/04woxqmrO/0Hd0QUB52PAB6PWECkS3jmELH4agMpi6c/LvCJvx8XXThKg3 VKsw== X-Forwarded-Encrypted: i=1; AJvYcCX2GhKT8K7UOSjAEFRlLKm9R6R2Ao9KJElxnQf29JJhcWU37UTC5OeFeL+8upWiBA0SNjME5d+PHkT4MvmiQdgWMtH3sTJ/BAUjvkzs X-Gm-Message-State: AOJu0YxH3J6M3xORgjTK1QORa/HFxghOV+Or66VOWbjgfLxZSHOSiosz yVaFuwyJb8Km1CgWRmIB3KbcJ2cfHKcfUDDXukF1hjlGvLxvT2YEnfHw7T16Ohc61pILNiRJ9E3 kfg== X-Google-Smtp-Source: AGHT+IEoiu5oVtBc2xte06xumcU1fR7G2fGD82bViLeMfqX3DwDl7AOxQ5irBK30N+71sDLyuskNw3VKqWs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1397:b0:6ea:8a0d:185f with SMTP id d2e1a72fcca58-6f4e02a64c3mr1357360b3a.2.1715967672755; Fri, 17 May 2024 10:41:12 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:39:24 -0700 In-Reply-To: <20240517173926.965351-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240517173926.965351-1-seanjc@google.com> X-Mailer: git-send-email 2.45.0.215.g3402c0e53f-goog Message-ID: <20240517173926.965351-48-seanjc@google.com> Subject: [PATCH v2 47/49] KVM: x86: Drop superfluous host XSAVE check when adjusting guest XSAVES caps From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Hou Wenlong , Kechen Lu , Oliver Upton , Maxim Levitsky , Binbin Wu , Yang Weijiang , Robert Hoo Content-Type: text/plain; charset="UTF-8" Drop the manual boot_cpu_has() checks on XSAVE when adjusting the guest's XSAVES capabilities now that guest cpu_caps incorporates KVM's support. The guest's cpu_caps are initialized from kvm_cpu_caps, which are in turn initialized from boot_cpu_data, i.e. checking guest_cpu_cap_has() also checks host/KVM capabilities (which is the entire point of cpu_caps). Cc: Maxim Levitsky Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 1 - arch/x86/kvm/vmx/vmx.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 06770b60c0ba..4aaffbf22531 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4340,7 +4340,6 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) * the guest read/write access to the host's XSS. */ guest_cpu_cap_change(vcpu, X86_FEATURE_XSAVES, - boot_cpu_has(X86_FEATURE_XSAVE) && boot_cpu_has(X86_FEATURE_XSAVES) && guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE)); diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 741961a1edcc..6fbdf520c58b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7833,8 +7833,7 @@ void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) * to the guest. XSAVES depends on CR4.OSXSAVE, and CR4.OSXSAVE can be * set if and only if XSAVE is supported. */ - if (!boot_cpu_has(X86_FEATURE_XSAVE) || - !guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE)) + if (!guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVE)) guest_cpu_cap_clear(vcpu, X86_FEATURE_XSAVES); vmx_setup_uret_msrs(vmx); -- 2.45.0.215.g3402c0e53f-goog