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

Re: [PATCH 5/5] x86/pv: Rewrite %dr6 handling


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 14 Sep 2023 18:06:28 +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=gA23pgaGUlyKDF6n68ya50akqejBJWakQw3dXMFGjXc=; b=HgZ0kx0KyMY/jvi/jr5kYlQJtEGLE0b8Jbvn0CQ3+56mjZsltIwraBIE8OrKscgOLuWtl4THRVSWGIu/QZLBtuAYrX/CKscDDlzeDOVBhmoUlE92p3r36LaeFzQNwuVEqP8ybFnoL2SkRvOqPTDj8VcRDH2Z2ZYVuggf4f1oUXgT7Cuxl40VE23uZC1B46SuQW4J08SNOAjPakHTB+2csnLsxuI6F0XZ/AafJhCnojLMd1pWeYy+izS2PMKiA4QzkHngv5mSehgtHYCZzrRC7FQwH4LJ6EO6w9QY4IfxcFD1vj53ah+v2IFiVeS1TlOAZ8gmjJRX4hl+d9LlW9gNfg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UV+Dn7aPOsYw3JiG4UELdseazJMqUxquPAnbCLu2CvlkqFGNUQGNRQ3E5LMiLxr7k93SoBs6kaUsx4cQOLBWj31Att3FuYM3FC7g+REn2dqXKYE+SEuWB95w13rO0T0HeS9v3PW3q+hru71S0QXcIbEBnZW8E4jIXr3AdQu+voNGWdc3tfVvBjgjgPIupF4XwynK9grUK781WUDLxhWdgkyBOVRf/xBaztHT41IqiJoPJE7cioDZQGEd1KZJdgsnPftchGR/A3L4jKov0n6FSaF4+NpJgg8dHmodDxN2gc/jWtWZ7rKJP653KoM5yCI+rKC0q0HxfpaghnsXLJwLUQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jinoh Kang <jinoh.kang.kr@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 14 Sep 2023 16:06:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.09.2023 01:21, Andrew Cooper wrote:
> --- a/xen/arch/x86/include/asm/domain.h
> +++ b/xen/arch/x86/include/asm/domain.h
> @@ -729,6 +729,18 @@ static inline void pv_inject_hw_exception(unsigned int 
> vector, int errcode)
>      pv_inject_event(&event);
>  }
>  
> +static inline void pv_inject_DB(unsigned long pending_dbg)
> +{
> +    struct x86_event event = {
> +        .vector      = X86_EXC_DB,
> +        .type        = X86_EVENTTYPE_HW_EXCEPTION,
> +        .error_code  = X86_EVENT_NO_EC,
> +        .pending_dbg = pending_dbg,

This being a sub-field of an unnamed union, the build will break (also
in pv_inject_page_fault() then, for cr2 being switched at the same time)
once again for old enough gcc.

> --- a/xen/arch/x86/pv/emulate.c
> +++ b/xen/arch/x86/pv/emulate.c
> @@ -71,11 +71,9 @@ void pv_emul_instruction_done(struct cpu_user_regs *regs, 
> unsigned long rip)
>  {
>      regs->rip = rip;
>      regs->eflags &= ~X86_EFLAGS_RF;
> +
>      if ( regs->eflags & X86_EFLAGS_TF )
> -    {
> -        current->arch.dr6 |= DR_STEP | DR_STATUS_RESERVED_ONE;
> -        pv_inject_hw_exception(X86_EXC_DB, X86_EVENT_NO_EC);
> -    }
> +        pv_inject_DB(X86_DR6_BS);
>  }

This (not your change, the construct) looks bogus at the first and second
glance, because of looking at EFLAGS.TF after emulation, when the initial
state of TF matters. It is only correct (at the third, closer look) because
the function presently is used only from paths not altering the guest's
EFLAGS. Do you think it would make sense to add a comment at this occasion?

Jan



 


Rackspace

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