From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fIs9a-0007pS-TX for speck@linutronix.de; Wed, 16 May 2018 10:51:23 +0200 Date: Wed, 16 May 2018 10:51:22 +0200 (CEST) From: Thomas Gleixner Subject: Re: [patch 10/15] Hidden 10 In-Reply-To: <20180516033835.GB26939@char.us.oracle.com> Message-ID: References: <20180513140048.543641807@linutronix.de> <20180513140539.060453691@linutronix.de> <20180516033835.GB26939@char.us.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Tue, 15 May 2018, speck for Konrad Rzeszutek Wilk wrote: > > +void > > +x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool guest) > > { > > - u64 host = x86_spec_ctrl_base; > > + u64 hostssbd = ssbd_tif_to_spec_ctrl(current_thread_info()->flags); > > Would it make sense to move the: > hostssbd = ssbd_tif_to.. > > > + u64 msr, host = x86_spec_ctrl_base; > > > > /* Is MSR_SPEC_CTRL implemented ? */ > > - if (!static_cpu_has(X86_FEATURE_MSR_SPEC_CTRL)) > > - return; > > - > > - /* SSBD controlled in MSR_SPEC_CTRL */ > > - if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD)) > > - host |= ssbd_tif_to_spec_ctrl(current_thread_info()->flags); > > - > > - if (host != guest_spec_ctrl) > > - wrmsrl(MSR_IA32_SPEC_CTRL, guest_spec_ctrl); > > -} > > -EXPORT_SYMBOL_GPL(x86_spec_ctrl_set_guest); > > - > > -/** > > - * x86_spec_ctrl_restore_host - Restore host speculation control registers > > - * @guest_spec_ctrl: The guest content of MSR_SPEC_CTRL > > - * @guest_virt_spec_ctrl: The guest controlled bits of MSR_VIRT_SPEC_CTRL > > - * (may get translated to MSR_AMD64_LS_CFG bits) > > - * > > - * Avoids writing to the MSR if the content/bits are the same > > - */ > > -void x86_spec_ctrl_restore_host(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl) > > -{ > > - u64 host = x86_spec_ctrl_base; > > - > > - /* Is MSR_SPEC_CTRL implemented ? */ > > - if (!static_cpu_has(X86_FEATURE_MSR_SPEC_CTRL)) > > - return; > > - > > - /* SSBD controlled in MSR_SPEC_CTRL */ > > - if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD)) > > - host |= ssbd_tif_to_spec_ctrl(current_thread_info()->flags); > > - > > - if (host != guest_spec_ctrl) > > - wrmsrl(MSR_IA32_SPEC_CTRL, host); > > + if (static_cpu_has(X86_FEATURE_MSR_SPEC_CTRL)) { > > + /* SSBD controlled in MSR_SPEC_CTRL */ > > + if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD)) > > + host |= hostssbd; > > to here? That is you are reading the ssbd_tif_to_spec_ctrl even if the > X86_FEATURE_MSR_SPEC_CTRL hasn't been enabled? (In theory, the compiler has > it probably optimized). Yes, I can move it. Thanks, tglx