[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.17 1/4] amd/virt_ssbd: set SSBD at vCPU context switch


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 13 Oct 2022 15:21:28 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fNS9IxhjXbPraLnCiQ3UlcAVBed+jkBVoJOA3z0D2CA=; b=QByp2i//eM5/aCEcx3Ppy3nx0rDwrLQ4rAtT/UDD9PGP9SFYBhiNhq290UbHzwlIl4UC/AdnBUVEnwwvJmIHmW390K8MjK+JYGgvxgCPdDxDatC4LN1mPjNsnOlRo3gmPF1bFjEcx/42EBk0pj7fLdSwvtGtSgySw4R38VdkZQYRMpzZhJZgSM01S/9jI/y+m6DAfwr/pPF5BSLVd+SiFOwVQKBWvS95srZYRtn2z/Fh4rlS+l0iRBpftU9SYm+zgDaD0V+D3hkFNgSRozj3WTGTfPUNgsAqKwpwU+kK9tfyj4GtzONrVNUhARvIxJAgYFKQ79o/UzduvJXeefqphQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tdb8cuD+XtiVo9BxclI6xu+vH66X+aW4JcutRa7HqzsjjsDf4HFyY/C2ppvoaDL3E2ZU4+1PwOnFiZj+IsH4zoV/mLFYLKZXjxbxbQSoIf1GTSSPro8QVhp4V/Grzs1KcY8LEfd4dP5h6qrQJPWbOj+aiFwf9SsKtVnB06N34zSPsTFaEumRnd78pT6HlKRabiDhsDVIc2ANamU7kVBLDUlK/QogNqR/tMccuIQ1hrlKix4zDCN9Aolp4WicsI2TfJtQqzl0+1XbAydxDJmx39pXMr5UESjObAJTA6soN4JjuJNieyBTXskCIFsvwiuLktOoxkLyVSmAomyQ3tGz4A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Henry.Wang@xxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 13 Oct 2022 13:21:47 +0000
  • Ironport-data: A9a23:y1/mOahWdsld2XnPXcNloymQX161VxEKZh0ujC45NGQN5FlHY01je htvX22FbqrYNzD9Kox2YNnk8U4A6pLWzd42TQBrry89Fiob9cadCdqndUqhZCn6wu8v7q5Ex 55HNoSfdpBcolv0/ErF3m3J9CEkvU2wbuOgTrSCYkidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+U4HUMja4mtC5AVmPKsT5TcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KT5p+ vk3NG0iVDusqfPozo+ZCfJOv9t2eaEHPKtH0p1h5RfwKK9+BLzmHeDN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvjiVlVQguFTuGIO9ltiiX8Jak1zev mvb12/4HgsbJJqUzj/tHneE1rWVzXilBdl6+LuQxPFNn0TPnWMqFTYaRVv8iqWfo0OEcocKQ 6AT0m90xUQoz2SpRNTgWxyzoFafowURHdFXFoUSyAyL0LuS3A+fCUANVDsHY9sj3OcpQRQ62 1nPmMnmbRR/vbvQRX+D+7O8qTKpJTNTPWIEfTUDTwYO/5/kuo5bs/7UZtNqEarwgtirHzj1m miOtHJn3+RVitMX3aKm+1yBmyirupXCUg8y4EPQQ36h6QR6IoWiYuRE9GTm0BqJF67BJnHpg ZTOs5L2ADwmZX1VqBGwfQ==
  • Ironport-hdrordr: A9a23:ITFly6mXGVwpnyqKufQ9H0Z7AWbpDfPJimdD5ihNYBxZY6Wkfp +V8cjzhCWftN9OYhodcLC7V5Voj0mskKKdxbNhRYtKPTOWwVdASbsP0WKM+V3d8kHFh41gPO JbAtND4b7LfCRHZKTBkW6F+r8bqbHokZxAx92uqUuFJTsaFp2IhD0JbjpzfHcGJjWvUvECZe ChD4d81k2dUEVSSv7+KmgOXuDFqdGOvJX6YSQeDxpizAWVlzun5JPzDhDdh34lInpy6IZn1V KAvx3y562lvf3+4hjA11XL55ATvNf60NNMCOGFl8BQADTxjQSDYphnRtS5zUYIidDqzGxvvM jHoh8mMcg2w3TNflutqR+o4AXk2CZG0Q6R9XaoxV/Y5eDpTjMzDMRMwahDdAHC1kYmtNZglI pWwmOwrfNsfF79tRW4w+KNewBhl0Kyr3Znu/UUlWZjXYwXb6IUhZAD/XlSDIwLEEvBmcoa+d FVfY7hDcttAB2nhyizhBgv/DXsZAV5Iv6+eDlPhiTPuAIm3EyQzCMjtb8idzk7hdEAoqJ/lp X525RT5c5zp/AtHNxA7cc6ML6K4z/2MGbxGVPXB2jbP4c6HF+Ig6LLwdwOlZGXkdozvdMPpK g=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Oct 12, 2022 at 10:26:19AM +0200, Jan Beulich wrote:
> On 11.10.2022 18:02, Roger Pau Monne wrote:
> > @@ -140,6 +135,7 @@ __UNLIKELY_END(nsvm_hap)
> >           */
> >          stgi
> >  GLOBAL(svm_stgi_label)
> > +
> >          mov  %rsp,%rdi
> >          call svm_vmexit_handler
> >          jmp  .Lsvm_do_resume
> 
> Seemingly stray change?

Urg, this was a squash of initially two separate patches and I didn't
pay enough attention at the end result not introducing such spurious
changes, sorry.

> > --- a/xen/arch/x86/hvm/svm/svm.c
> > +++ b/xen/arch/x86/hvm/svm/svm.c
> > @@ -973,6 +973,14 @@ static void cf_check svm_ctxt_switch_from(struct vcpu 
> > *v)
> >  
> >      /* Resume use of ISTs now that the host TR is reinstated. */
> >      enable_each_ist(idt_tables[cpu]);
> > +
> > +    /*
> > +     * Clear previous guest selection of SSBD if set.  Note that 
> > SPEC_CTRL.SSBD
> > +     * is already cleared by svm_vmexit_spec_ctrl.
> > +     */
> > +    if ( v->domain->arch.cpuid->extd.virt_ssbd &&
> 
> With this false, can ...
> 
> > +         (v->arch.msrs->virt_spec_ctrl.raw & SPEC_CTRL_SSBD) )
> 
> ... this bit ever be set? IOW if the former condition actually needed here?

Hm, right, I guess it's not helpful to gate accessing the field to the
CPUID bit, as it should never be set otherwise.

> > +        amd_set_ssbd(false);
> >  }
> >  
> >  static void cf_check svm_ctxt_switch_to(struct vcpu *v)
> > @@ -1000,6 +1008,11 @@ static void cf_check svm_ctxt_switch_to(struct vcpu 
> > *v)
> >  
> >      if ( cpu_has_msr_tsc_aux )
> >          wrmsr_tsc_aux(v->arch.msrs->tsc_aux);
> > +
> > +    /* Load SSBD if set by the guest. */
> > +    if ( v->domain->arch.cpuid->extd.virt_ssbd &&
> > +         (v->arch.msrs->virt_spec_ctrl.raw & SPEC_CTRL_SSBD) )
> > +        amd_set_ssbd(true);
> >  }
> 
> Same here then.
> 
> > @@ -2518,6 +2531,10 @@ static void cf_check svm_set_reg(struct vcpu *v, 
> > unsigned int reg, uint64_t val)
> >          vmcb->spec_ctrl = val;
> >          break;
> >  
> > +    case MSR_VIRT_SPEC_CTRL:
> > +        amd_set_ssbd(v->arch.msrs->virt_spec_ctrl.raw);
> 
> Would seem cheaper to pass "val & SPEC_CTRL_SSBD" here.

Yes, a couple less dereferences.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.