xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Stefan ISAILA <aisaila@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Petre Ovidiu PIRCALABU <ppircalabu@bitdefender.com>,
	"tamas@tklengyel.com" <tamas@tklengyel.com>,
	"wl@xen.org" <wl@xen.org>,
	"rcojocaru@bitdefender.com" <rcojocaru@bitdefender.com>,
	"george.dunlap@eu.citrix.com" <george.dunlap@eu.citrix.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"paul.durrant@citrix.com" <paul.durrant@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v7] x86/emulate: Send vm_event from emulate
Date: Tue, 30 Jul 2019 14:12:13 +0000	[thread overview]
Message-ID: <c7060d91-851a-ba04-56c3-90f1aed65913@bitdefender.com> (raw)
In-Reply-To: <60651ad5-f0bd-caad-77f6-5f8fb71a8319@suse.com>



On 30.07.2019 16:27, Jan Beulich wrote:
> On 30.07.2019 14:21, Alexandru Stefan ISAILA wrote:
>>
>>>>>>> @@ -629,6 +697,14 @@ static void *hvmemul_map_linear_addr(
>>>>>>>         
>>>>>>>                     ASSERT(p2mt == p2m_ram_logdirty || !p2m_is_readonly(p2mt));
>>>>>>>                 }
>>>>>>> +
>>>>>>> +        if ( curr->arch.vm_event &&
>>>>>>> +            curr->arch.vm_event->send_event &&
>>>>>>> +            hvm_emulate_send_vm_event(addr, gfn, pfec) )
>>>>>>> +        {
>>>>>>> +            err = ERR_PTR(~X86EMUL_RETRY);
>>>>>>> +            goto out;
>>>>>>> +        }
>>>>>>
>>>>>> Did you notice that there's an immediate exit from the loop only
>>>>>> in case the linear -> physical translation fails? This is
>>>>>> relevant for page fault delivery correctness for accesses
>>>>>> crossing page boundaries. I think you want to use
>>>>>> update_map_err() and drop the "goto out". I can't really make up
>>>>>
>>>>> By update_map_err() are you saying to have the err var assigned and then
>>>>> drop "goto out"? If so how do I keep the err from my access violation
>>>>> without exiting from the loop?
>>>>
>>>> Counter question: Why do you _need_ to keep "your" value of err?
>>>> If, just as an example, there's going to be a #PF on the other
>>>> half of the access, then "your" access violation is of no interest
>>>> at all.
>>>
>>> You are right, there is no need to keep the "goto out" here. It was just
>>> for optimization in the idea that there is no need to do further steps
>>> but I can drop the "goto out" and the code will work the same.
>>>
>>
>> There is a problem with dropping the "goto out". If everything goes fine
>> then it will return the mapping and I don't want that. This can be
>> stopped by checking if ( err ) after the loop and it is not null then
>> goto out. And going with this idea I can init *err = NULL and drop the
>> err = NULL from hvmemul_map_linear_addr(). Is this ok for the next version?
> 
> I'd prefer to see the code to decide. If you want this settled before
> sending the next full version, then please send at least the resulting
> patch hunk(s).
> 

Here is a diff for hvmemul_map_linear_addr():


diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index d75d3e6fd6..49dbfa730c 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -543,10 +543,11 @@ static void *hvmemul_map_linear_addr(
      struct hvm_emulate_ctxt *hvmemul_ctxt)
  {
      struct vcpu *curr = current;
-    void *err, *mapping;
+    void *err = NULL, *mapping;
      unsigned int nr_frames = ((linear + bytes - !!bytes) >> PAGE_SHIFT) -
          (linear >> PAGE_SHIFT) + 1;
      unsigned int i;
+    gfn_t gfn;

      /*
       * mfn points to the next free slot.  All used slots have a page 
reference
@@ -585,7 +586,7 @@ static void *hvmemul_map_linear_addr(
          ASSERT(mfn_x(*mfn) == 0);

          res = hvm_translate_get_page(curr, addr, true, pfec,
-                                     &pfinfo, &page, NULL, &p2mt);
+                                     &pfinfo, &page, gfn, &p2mt);

          switch ( res )
          {
@@ -599,7 +600,6 @@ static void *hvmemul_map_linear_addr(
              goto out;

          case HVMTRANS_bad_gfn_to_mfn:
-            err = NULL;
              goto out;

          case HVMTRANS_gfn_paged_out:
@@ -622,14 +622,22 @@ static void *hvmemul_map_linear_addr(
              }

              if ( p2mt == p2m_ioreq_server )
-            {
-                err = NULL;
                  goto out;
-            }

              ASSERT(p2mt == p2m_ram_logdirty || !p2m_is_readonly(p2mt));
+
+            if ( curr->arch.vm_event &&
+                 curr->arch.vm_event->send_event &&
+                 hvm_emulate_send_vm_event(addr, gfn, pfec) )
+                err = ERR_PTR(~X86EMUL_RETRY);
          }
      }
+    /* Check if any vm_event was sent */
+    if ( err )
+        goto out;

      /* Entire access within a single frame? */
      if ( nr_frames == 1 )


Alex
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-07-30 14:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 10:56 [Xen-devel] [PATCH v7] x86/emulate: Send vm_event from emulate Alexandru Stefan ISAILA
2019-07-11 17:13 ` Tamas K Lengyel
2019-07-12  1:28   ` Jan Beulich
2019-07-15  8:52     ` Alexandru Stefan ISAILA
2019-07-18 12:58 ` Jan Beulich
2019-07-19 12:34   ` Alexandru Stefan ISAILA
2019-07-19 13:18     ` Jan Beulich
2019-07-19 13:30       ` Razvan Cojocaru
2019-07-19 13:38         ` Jan Beulich
2019-07-19 14:23           ` Razvan Cojocaru
2019-07-29  8:12             ` Alexandru Stefan ISAILA
2019-07-29 11:30               ` Jan Beulich
2019-07-22  7:51       ` Alexandru Stefan ISAILA
2019-07-30 12:21         ` Alexandru Stefan ISAILA
2019-07-30 13:27           ` Jan Beulich
2019-07-30 14:12             ` Alexandru Stefan ISAILA [this message]
2019-07-30 14:54               ` Jan Beulich
2019-07-30 15:28                 ` Alexandru Stefan ISAILA
2019-08-20 20:11                 ` Andrew Cooper
2019-08-27  8:26                   ` Jan Beulich
2019-09-02 14:36                     ` Alexandru Stefan ISAILA
2019-09-02 14:59                       ` Jan Beulich
2019-07-23  8:17       ` Alexandru Stefan ISAILA

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7060d91-851a-ba04-56c3-90f1aed65913@bitdefender.com \
    --to=aisaila@bitdefender.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=paul.durrant@citrix.com \
    --cc=ppircalabu@bitdefender.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=roger.pau@citrix.com \
    --cc=tamas@tklengyel.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).