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

Re: [PATCH 3/3] x86/PV: drop "vcpu" local variable from show_guest_stack()


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 18 Oct 2021 16:57:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=u8lDDQNRK3N89R4dW4qpZUfSavb1/N19lrDkKZSIOls=; b=YbS8izPVr0DKeGqqEEsu2dSqtZaQgL4MQjw351YgoygLo+rIx1PpUpNhZRBoHDQx2hP2k9MACVlQSzSfVlgAfNU8HZb4i4DkEXb6l4Cj2pIVX7E1djBc94NHtvjgZboJip4MFonLkla9dJ5gk5hyEsV26uu/J73j64RK0uEsn0TsJjGDGg5cLnVhOv9aBk5OyBktWl2MQLzVvg3F5qt8U/JXqEiNbp62CF/AsGShGLXVYCVGmFs/zrpaNuXMZ4lVS70vIUgJKQYqOHn7r5niJHB+sqE7oFZExAOyUNmGDI6rEdLmAlohDidimxxMqhb6BsZHydCyUjoBbAk2ewqYWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LbYXCBJOI9KISs3Tu4BZW1jSFITlseZWsyZGhjiaqe6t5wfyHqfKasV59Vi4gVKwVt/f9bFt1kNy8Mg/MHxzIAb+YWNmvYUDHdlXQLvrL7FiTg8xteBpfIYFYLzVwdTJc9zZfmWkpBqvn6jbiREzHFKQLE7o8CFBcNIAncuHsTfxN8Ln0WfhNHYR6e1JnPrZhVcX32tt/zSm3XSDk9nQQyfQ3YrwfeL7FfXCuOWps/nikrUwrPYvGrTGFnFMadhQ565tzpZqjzxpGCd9FIrFqzoyOhRjNtUn6al2XHJ4QdfustijOqSWMudKGYJLs+7YStCdMGiXOMHZFgGO1JQ5SQ==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 18 Oct 2021 14:58:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18.10.2021 16:35, Roger Pau Monné wrote:
> On Wed, Sep 29, 2021 at 11:43:32AM +0200, Jan Beulich wrote:
>> It's not really needed and has been misleading me more than once to try
>> and spot its "actual" use(s). It should really have been dropped when
>> the 32-bit specific logic was purged from here.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

> As it makes the current code clearer. I have one question/concern
> below.
> 
>> --- a/xen/arch/x86/traps.c
>> +++ b/xen/arch/x86/traps.c
>> @@ -327,16 +327,13 @@ static void show_guest_stack(struct vcpu
>>  
>>      if ( v != current )
>>      {
>> -        struct vcpu *vcpu;
>> -
>>          if ( !guest_kernel_mode(v, regs) )
>>          {
>>              printk("User mode stack\n");
>>              return;
>>          }
>>  
>> -        vcpu = maddr_get_owner(read_cr3()) == v->domain ? v : NULL;
>> -        if ( !vcpu )
>> +        if ( maddr_get_owner(read_cr3()) != v->domain )
> 
> Wouldn't it be more accurate to check that the current loaded cr3
> matches the one used by v?
> 
> AFAICT we don't load the cr3 from v, so it's still possible to have
> diverging per-vcpu page tables and thus end up dumping wrong data?

I think truly per-CPU page tables in a PV guest would be quite
cumbersome to have. And iirc (it's been over 12 years since introducing
that logic) the check also isn't about the CR3 we're on being the one
associated with the present vCPU, but merely whether we can expect that
page to be mapped. This would also fall apart when a remote vCPU's
stack isn't accessible on the current CPU for whichever other reason.
I'd be inclined to further tighten this (and force more cases through
do_page_walk()) when we see evidence that we need doing so.

Jan




 


Rackspace

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