From: "Jan Beulich" Subject: Re: [PATCH] x86/AMD: Add support for AMD's OSVW feature in guests Date: Tue, 31 Jan 2012 10:13:40 +0000 Message-ID: <4F27CCE40200007800070120@nat28.tlf.novell.com> References: <1361d9895cb17aa8fce1.1327943146@wotan.osrc.amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1361d9895cb17aa8fce1.1327943146@wotan.osrc.amd.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Boris Ostrovsky Cc: Christoph.Egger@amd.com, xen-devel@lists.xensource.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 30.01.12 at 18:05, Boris Ostrovsky wrote: > --- a/xen/arch/x86/microcode.c Thu Jan 26 17:43:31 2012 +0000 > +++ b/xen/arch/x86/microcode.c Mon Jan 30 18:00:50 2012 +0100 > @@ -218,6 +218,16 @@ int microcode_update(XEN_GUEST_HANDLE(co > info->error = 0; > info->cpu = cpumask_first(&cpu_online_map); > > + if ( microcode_ops->start_update ) > + { > + ret = microcode_ops->start_update(); > + if ( ret != 0 ) > + { > + xfree(info); > + return ret; > + } Indentation (no tabs). > + } > + > return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); > } > > --- a/xen/arch/x86/microcode_amd.c Thu Jan 26 17:43:31 2012 +0000 > +++ b/xen/arch/x86/microcode_amd.c Mon Jan 30 18:00:50 2012 +0100 > @@ -337,13 +341,18 @@ static int cpu_request_microcode(int cpu > /* On success keep the microcode patch for > * re-apply on resume. > */ > - if (error == 1) > + if ( error == 1 ) > { > xfree(mc_old); > - return 0; > + error = 0; > + } else } else > + { > + xfree(mc_amd); > + uci->mc.mc_amd = mc_old; > } > - xfree(mc_amd); > - uci->mc.mc_amd = mc_old; > + > + out: > + svm_host_osvw_init(); > > return error; > } > --- a/xen/arch/x86/platform_hypercall.c Thu Jan 26 17:43:31 2012 +0000 > +++ b/xen/arch/x86/platform_hypercall.c Mon Jan 30 18:00:50 2012 +0100 > @@ -166,7 +166,17 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe > break; > > guest_from_compat_handle(data, op->u.microcode.data); > + > + while ( !domctl_lock_acquire() ) It's not clear to me what you're trying to protect against here. I don't think this prevents guests from making progress (and hence possibly seeing the intermediate [and wrong] OSVW state between svm_host_osvw_reset() and svm_host_osvw_init()). Jan > + if ( hypercall_preempt_check() ) > + { > + ret = hypercall_create_continuation( > + __HYPERVISOR_platform_op, "h", u_xenpf_op); > + goto out; > + } > + > ret = microcode_update(data, op->u.microcode.length); > + domctl_lock_release(); > } > break; >