Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1110336lqo; Fri, 17 May 2024 10:57:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHSMF1B72Htw9KW0noQevq9W6PY9bnMoqCLCFM6mQ0MMDeCYuVNVvFwkXju1eshZJIJdnE2N+s7GW8xLp1l5Gvga0hyUOuY9puNKcKBw== X-Google-Smtp-Source: AGHT+IFZvhoI//CmbjIN2MHHZc9HAyYRZxtyIv79Kyb2LJpiTo7sH9M1RrhQB+971xHz5VOKIu5O X-Received: by 2002:a17:90a:4087:b0:2b6:c651:68b with SMTP id 98e67ed59e1d1-2b6cc758385mr19280090a91.12.1715968630599; Fri, 17 May 2024 10:57:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968630; cv=pass; d=google.com; s=arc-20160816; b=OLYnQjrV2HXi5QyYeWVX/pnomRfOWRcmtVf3HPVGEoaCcI/cbN/EteZ35H796eugpH sbQ9QMaUrqlJ/6i8xHgb9ZjJxeEGUJVqFqzGvS1laLN1NUdPfcJptZ0y88u2JQlgIzaQ d8T/QIe8GGUQzwMp7igglBdOdMnanGRmWAyfb4GQXhN3tSTCtqU744NShBnKxUY0plN7 IbfDyJGUM/y54a+cb1fUJdYBsT20kyL65AvxEyDbvFceFMTIpOzKfNzLiTxT/iA9qfHe YSZiuG/pcRAmeTAM8CaH02Y6Jv1hVDwu0fH7x2uuHfdzAzK+dlWVoqAdNCTSNGvvrqU8 tiOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=tJWRXOUZEf0tFhXUEsVYsHdLmAwURDTHhDYt6uCUFks=; fh=jHJVZSez0VknU3nKb/y+6RXEGi9e6ELmE6kVnZEzr5M=; b=nsZZHzIzEgVAn9fqAOl1P6bwv9FAq1U1E0lIJTe8ipJpZobKH9i8or/d/5hq0v10BF 9Jz1lE8TjTK0HZSsGcN21TY/RzH5uocuV9zFTYfPF+sVgDyz4dCfMztW1LZbuKHXExgZ 78jH8t8uK5hjpp+iKstQhcadY/3Fhc1XLPNR9Lr05I7D2oUGclzfI7XOHoJSYBTQoDsW saqiP6Vx8d3TOCha/pH3ExqxNzSj3bbn8/1gzDHdT7CB9M4PUXGrBQ5qqKXn3/XqWA3D +0SllDYkOrzDwZPxVTf1G6zYw2Qdsd1S/SdjZerKes4ivDkoRu5uF8qlJMKfdrN5m23y 2qNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cneBLwrI; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182481-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-64ed9fafbeasi4101124a12.481.2024.05.17.10.57.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182481-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; dkim=pass header.i=@google.com header.s=20230601 header.b=cneBLwrI; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182481-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 49E052865AE for ; Fri, 17 May 2024 17:54:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7859515B0EE; Fri, 17 May 2024 17:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cneBLwrI" 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 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-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