From patchwork Mon Jun 17 21:04: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: 13701428 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 AEB911990DB for ; Mon, 17 Jun 2024 21:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718658282; cv=none; b=NSVsd8bIi5P47J29NfSvNRgtQv9APSti+1X0p0YP8g7vYtEGVOdTPhLTAdZOhKJsPS904lNQHJRZ2xRg31UptiatISXL3kc5mknf8tEKC3w/DnMu3HSmBx97zDnYtrcdwv6yvDWzwEeMq0fOus+1ohcRiL+InPVd/g7se+uHO5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718658282; c=relaxed/simple; bh=GgL7C4XsGZdaFxvhCSzn6B1D7vD9GsUfOgTNCMHcqTQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=t8T3gWiTa5Q2+vc0fiWnW7w12VHr/My4B7izqMFBgSzM1Ojai7wRrmK5+vlAkSkcCqPOWCku/cU2WTfpQRJF9Alb1RmPawARWwBr8OJP4gcN/3c9NpewevGfLDsjwS9g4X5k9hapItYo5XS8afITPxMoxow8f9izeLsD2og9tHs= 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=wAbJF69U; arc=none smtp.client-ip=209.85.219.201 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="wAbJF69U" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dfdfe3d9fc8so9849603276.3 for ; Mon, 17 Jun 2024 14:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718658280; x=1719263080; 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=NgijcnX9grOHrgyIejX0z10b3CCYWPg+W4dYSETE15U=; b=wAbJF69Ug+Prkwb0ppufoBhN2L9ZZkHJP6Zvs6pXiLx1rDKV9aCz9l6Z5vqG916GRg QRXsGGDeUn+XgD8bp3OOSzHozOMLYvLacUpeoEgN0SFAQr4Zrmewa4AvEdxjsN9JHlyp IMCNjVTpCy8ozgc6JaIK19NTwDsUeSUzglKzNt6G6inn9N0U9I2jrTqgcnu7i5DVXSCE leaUxZuwy5+RZIh0az8UaB7JGEsHhp/n9ZQEiLNQrEr52u0wXlzyBG/3mh50+GPCOXcx oYiedgYPn2KrsibXGZOfErdY65zv+XY/RQtm3/ekqf1+h8dZzc/DIJLkCBmQx44txqu2 Qfdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718658280; x=1719263080; 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=NgijcnX9grOHrgyIejX0z10b3CCYWPg+W4dYSETE15U=; b=jYdtOW+dJEQMLwNJwylpa7LxbrejKxlFi9vtOryEkvN/noLz6q4EtIzo2HcdzUDZd8 kxuV691LwBLtAtlQvyL3InodoN2y86BfQw9Kv5t3021h+n40rYzQc+BtqsoCnZphEq7e XuuzHKERNXcj3h9uHan5NoxJjSDN6nMB3QG/b3at7suMBqRslUzC0ApXtymEzWG0x8c7 7/5ADWqsRgmKJSrnsm9U6H13DhREX/myqdat/VTgWJzML7txKZnV3yWyitsCFJLkXwv3 H3OusZhrLxjUTKUcT9BUSW7BApQYEkbgpzGVSQwXh6EopeYmZ5JHJQIfB0PW2q+a4eLq tWxQ== X-Gm-Message-State: AOJu0YxU+o1gM3N68sexLfAfa3DF7j6RXF305j9wZ6sZJ/+vxoZ+yip5 zOid+EKKmy7f4c7I1wQlbsc/IQCfsFYIgJvkit/cBRJeueUV4XoBzYzAxz90CAwIAA2usjPcq/b MzA== X-Google-Smtp-Source: AGHT+IGh5JSyqQ78f+320CinlxtTglmN1fuD+EdaVZ3qjNH/w5QNMBcaH6q3i7SxIBU+oaFNIg4KR/RtK98= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1027:b0:dfe:1633:89e9 with SMTP id 3f1490d57ef6-dff1535749dmr3599808276.1.1718658279636; Mon, 17 Jun 2024 14:04:39 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 17 Jun 2024 14:04:30 -0700 In-Reply-To: <20240617210432.1642542-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240617210432.1642542-1-seanjc@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240617210432.1642542-2-seanjc@google.com> Subject: [PATCH 1/3] KVM: SVM: Force sev_es_host_save_area() to be inlined (for noinstr usage) From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov Force sev_es_host_save_area() to be always inlined, as it's used in the low level VM-Enter/VM-Exit path, which is non-instrumentable. vmlinux.o: warning: objtool: svm_vcpu_enter_exit+0xb0: call to sev_es_host_save_area() leaves .noinstr.text section vmlinux.o: warning: objtool: svm_vcpu_enter_exit+0xbf: call to sev_es_host_save_area.isra.0() leaves .noinstr.text section Fixes: c92be2fd8edf ("KVM: SVM: Save/restore non-volatile GPRs in SEV-ES VMRUN via host save area") Reported-by: Borislav Petkov Signed-off-by: Sean Christopherson Tested-by: Borislav Petkov (AMD) --- arch/x86/kvm/svm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 9ac6fca50cf3..0a36c82b316f 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1504,7 +1504,7 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu) __free_pages(virt_to_page(svm->msrpm), get_order(MSRPM_SIZE)); } -static struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd) +static __always_inline struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd) { return page_address(sd->save_area) + 0x400; } From patchwork Mon Jun 17 21:04:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13701429 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 6CDFD199224 for ; Mon, 17 Jun 2024 21:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718658283; cv=none; b=BUS2iK4FZMCtzDrOtLhszbn1uupPj0USz623/Wr4ReYKm6Jcw7GAsMDYy1abdF7j0AVGVvjOgFGk78XZhKeIuW8mwhpVFOQmWEJNws5c7U0Ho53piWPHNz31ORelttLS9eU2GE42w6lbrSG3RTlC8dP4AjLxTeXlMBd5G35KP2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718658283; c=relaxed/simple; bh=hW9s4YrD2rYCAtJQRgt3dFVi5jTxIwhW6X+oURrgKkE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EsnDiluVQV9YV8Au6uSva2wHj7D6js1DpWwarekBWWyBKocvBXBJRbEP30KExVOdZRegmobkCRCoivkZDAdPYoQ2NAxuUWgSguRpJW2nvyME00jhiugqoJI2W7vtQc4aARtHv+eFxQp5X1n8Ppla87glc4JthRh0EHiXzfQz61U= 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=T9S7Qxqr; arc=none smtp.client-ip=209.85.214.201 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="T9S7Qxqr" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1f6174d0421so40122105ad.2 for ; Mon, 17 Jun 2024 14:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718658282; x=1719263082; 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=Elx1e+10wUymCoKo0AgjMeEwTIxlGaxO8TxJhQWkuZw=; b=T9S7QxqrZ+ulfy8M51ARGUBFCTwVo1ZMj3qOP+hLySX12kR4eu8QfRj8uUOP9tc4gX pp69/jYpB0SnoVH/4DhrIsUNPeib4VSF9XWPN5kCyhpzrUqM3En9kF6tDCluEv2AA1Gq y5egr/BpD+UkVP9aMgfu0NautNm2AZctYzmDECFR5uXv6CahONvvI6ictdGs6/fnJBWL f7q5+vm5Ga1/EjnFwQToIS2tpfU0DFq1j08yAKKKRXpb37WadrPIk8WbLqh8yU76KOjg zwlbFzhYVwWaiL3bVZMIv8EJRJ+zp9lpuqX2/yYFFVLaTfBTmNyfeFDsB4HxGcla+pqq bnHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718658282; x=1719263082; 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=Elx1e+10wUymCoKo0AgjMeEwTIxlGaxO8TxJhQWkuZw=; b=ArdESWBX5QIvyEMaffh5qkeuJZei477+q6r4qoLkwoE7QcJ9i+sl0je2j4rcIMGmw5 2UxtCqRvlCzAnyRX21zc/APBa71/0dfWMUO3e0Jwyl/3ylcQZpDXoTqgb8SgxRQ3iqHJ jNz+y80CTIXK2uXYTlhPaeHfyA8Ar/GivMimtw1Jw0WyroirrXKzYO+fShDgADQEs0oY Ltet3190FSMwtk4+Y7rqyycdN2SNu3jKbZssxaCtOnExRNDZUMNn7mvvjLmPWiMNiDHU SdVR9mvtkJhXCNGIfEGvPtl7vA4ieRE/G0TBd7KCoG1o7MczBg25i3OTW6U5tN67WHhU rmTg== X-Gm-Message-State: AOJu0YzqO0/e4ajCjOaSSWCN6aK2Loc3hmkj33IuizgHR7xYioDloC7Q K6I9IeFF7OZ1/Mzy/1Tm+qf76NBCUW+eeA2fuEbqAWrZ5uk/c2L0KjLD/XosAMhmpkTLSsitpnQ /fQ== X-Google-Smtp-Source: AGHT+IHVcy4Y7j/c4US2yEpq6Hsh5op4svsWFM9kBP2pbYfmm5OrsaaeQugHwwc3NlorTSy3w0NBPfkPyY8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2452:b0:1f7:3bb3:abe2 with SMTP id d9443c01a7336-1f8629fcc75mr1488075ad.12.1718658281620; Mon, 17 Jun 2024 14:04:41 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 17 Jun 2024 14:04:31 -0700 In-Reply-To: <20240617210432.1642542-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240617210432.1642542-1-seanjc@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240617210432.1642542-3-seanjc@google.com> Subject: [PATCH 2/3] KVM: SVM: Use sev_es_host_save_area() helper when initializing tsc_aux From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov Use sev_es_host_save_area() instead of open coding an equivalent when setting the MSR_TSC_AUX field during setup. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 0a36c82b316f..cf285472fea6 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -570,6 +570,11 @@ static void __svm_write_tsc_multiplier(u64 multiplier) __this_cpu_write(current_tsc_ratio, multiplier); } +static __always_inline struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd) +{ + return page_address(sd->save_area) + 0x400; +} + static inline void kvm_cpu_svm_disable(void) { uint64_t efer; @@ -674,12 +679,9 @@ static int svm_hardware_enable(void) * TSC_AUX field now to avoid a RDMSR on every vCPU run. */ if (boot_cpu_has(X86_FEATURE_V_TSC_AUX)) { - struct sev_es_save_area *hostsa; u32 __maybe_unused msr_hi; - hostsa = (struct sev_es_save_area *)(page_address(sd->save_area) + 0x400); - - rdmsr(MSR_TSC_AUX, hostsa->tsc_aux, msr_hi); + rdmsr(MSR_TSC_AUX, sev_es_host_save_area(sd)->tsc_aux, msr_hi); } return 0; @@ -1504,11 +1506,6 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu) __free_pages(virt_to_page(svm->msrpm), get_order(MSRPM_SIZE)); } -static __always_inline struct sev_es_save_area *sev_es_host_save_area(struct svm_cpu_data *sd) -{ - return page_address(sd->save_area) + 0x400; -} - static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); From patchwork Mon Jun 17 21:04:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13701430 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 98F411993BE for ; Mon, 17 Jun 2024 21:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718658286; cv=none; b=iixzpE/EB0qA5qtTONkbjQtgK0IeadChKR3nwTAro1NoSXBUt76np5KRFSYVryHBn7YZinzhYOh/heCxyRYzDe6kVmlgxDaRmt7eiDt3dbGYr1TtURNcWQsjBKmCrzduzgM4nLbTVxj/EPXxDLwKHcVyd+q8yKau0e6eR04WIq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718658286; c=relaxed/simple; bh=abcNN6/yOl1D2N06tiJ3hT0s2jLzDjcN7nV9gnKoViE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hikzASWJYfNJSV0jmtA+b/uTkSaQrxxfRURHzkcc510jKCFVhDdS7IU2iWDPYD2tRc67YfxZ9WA0xm9zDC/4fDP8tvMTGUugnr2vMMnWQJ3i5ySdwrAAQr/N4MoOCqwQLnN5v3vFA0JzcS5jsoGBFSIpTFQEQEceUimLVNlACHM= 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=tYMgxtG1; arc=none smtp.client-ip=209.85.128.201 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="tYMgxtG1" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6338f71a577so54059757b3.1 for ; Mon, 17 Jun 2024 14:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718658283; x=1719263083; 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=+W/+ANKl6aDY00ytIycx9vklTfPR8Zq4BBj+gxYemOg=; b=tYMgxtG1fxADn2T9ChLOoUlEIcv4hZIyXdgj3JvGK/sE9J92R8Rg2M+L6E3FAA/ZDi aMInrbnQnqZdkHRNCkvro5C3e4Dt3NUCknUtLkjKdO8dV8+lfy9HecmdKha0ZNrTcM7i n2XkHnInCV94sMqEc2jYZlVgtVYqx+aKO36cB3skcl188fsE83S1CMnDcKQYuHoY7SYM d2R5nQJ3rx38oPk8um6D07NdGeuYEmaxFMZGHWITCIUF+dG9OX6LuEjSUIYt7sc2/Jq9 Qb9Kzl2FPqLqWYQHant/QKwZfKA3KjgYMq71HIyCx5/VzhFmiylCSnz2a8fkDhpllb7D hzbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718658283; x=1719263083; 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=+W/+ANKl6aDY00ytIycx9vklTfPR8Zq4BBj+gxYemOg=; b=OQ3h1vcB7JzmcgFHIQEuy7Hm7PEdJI9CcJwYZti/HqyxPJ5pXvKJJBB1Xf3b1bmAtp HwyP541O32ylGzwsaF/gZaxHMqZ+SygxtEQ2C6CjugNMo8AF8bE2Abt1hpEE4mu+PUOe M1tGkkV/7BNzLnXrq/Kzlvog0xw+RfJxqa4mMNnRfh09hZu4Wml7r9DevMoZpYBHzJP8 Ee/pt0tfLNxdjpi/BMjerEMbu6t4cUHGctSJcUsucjJ6M9ZMh41nti9E9ZvGp+YE2G9I EXO/LavnFNXzRlvZZWtgGcGfEPHoOaedDMQE65zIOKoUpQ4HZguNwh67WlZk58TFrGjn PIFA== X-Gm-Message-State: AOJu0YxJh1mOyVl1dwd5Bdv3PEiSo0oX10fOU0gfrHluP2sMrJO/bZbW HHqK8pR4WOZIrG3mffyi/EiFzqi+aPHIgq0w6LjPJjxOLgfJBgOcj3gzpmE2BTaoJKB/kMDZPdm 6Kg== X-Google-Smtp-Source: AGHT+IEN6Rwwh4iwjkOFUoqjrBzVaK6d8aiiHhe3RLuNcj2xLyObA9Gk4dpr4kRqjva8iIoe6Ang/bKSdPE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1b84:b0:de5:bc2f:72bb with SMTP id 3f1490d57ef6-dff1554e6cdmr1092359276.12.1718658283661; Mon, 17 Jun 2024 14:04:43 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 17 Jun 2024 14:04:32 -0700 In-Reply-To: <20240617210432.1642542-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240617210432.1642542-1-seanjc@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Message-ID: <20240617210432.1642542-4-seanjc@google.com> Subject: [PATCH 3/3] KVM: SVM: Use compound literal in lieu of __maybe_unused rdmsr() param From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov When reading MSR_TSC_AUX, which is effectively a 32-bit value, use a compound literal to consume/ignore the upper 32 bits instead of a "maybe" unused local variable. While (ab)using a compound literal to discard an unused output is unusual, it's perfectly legal as compound literals are valid, modifiable l-values in C99 and beyond. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index cf285472fea6..69c0dea5cc0d 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -678,11 +678,8 @@ static int svm_hardware_enable(void) * Since Linux does not change the value of TSC_AUX once set, prime the * TSC_AUX field now to avoid a RDMSR on every vCPU run. */ - if (boot_cpu_has(X86_FEATURE_V_TSC_AUX)) { - u32 __maybe_unused msr_hi; - - rdmsr(MSR_TSC_AUX, sev_es_host_save_area(sd)->tsc_aux, msr_hi); - } + if (boot_cpu_has(X86_FEATURE_V_TSC_AUX)) + rdmsr(MSR_TSC_AUX, sev_es_host_save_area(sd)->tsc_aux, (u32){0}); return 0; }