From: Kai Huang <kai.huang@linux.intel.com>
To: Tim Deegan <tim@xen.org>
Cc: yang.z.zhang@intel.com, andrew.cooper3@citrix.com,
kevin.tian@intel.com, jbeulich@suse.com, xen-devel@lists.xen.org
Subject: Re: [PATCH 05/10] VMX: add help functions to support PML
Date: Fri, 10 Apr 2015 15:05:46 +0800 [thread overview]
Message-ID: <5527764A.506@linux.intel.com> (raw)
In-Reply-To: <20150409120033.GF17031@deinos.phlegethon.org>
On 04/09/2015 08:00 PM, Tim Deegan wrote:
> Hi,
>
> At 10:35 +0800 on 27 Mar (1427452549), Kai Huang wrote:
>> +void vmx_vcpu_flush_pml_buffer(struct vcpu *v)
>> +{
>> + uint64_t *pml_buf;
>> + unsigned long pml_idx;
>> +
>> + ASSERT(vmx_vcpu_pml_enabled(v));
>> +
>> + vmx_vmcs_enter(v);
>> +
>> + __vmread(GUEST_PML_INDEX, &pml_idx);
>> +
>> + /* Do nothing if PML buffer is empty */
>> + if ( pml_idx == (PML_ENTITY_NUM - 1) )
>> + goto out;
>> +
>> + pml_buf = map_domain_page(page_to_mfn(v->arch.hvm_vmx.pml_pg));
>> +
>> + /*
>> + * PML index can be either 2^16-1 (buffer is full), or 0~511 (buffer is not
>> + * full), and in latter case PML index always points to next available
>> + * entity.
>> + */
>> + if (pml_idx >= PML_ENTITY_NUM)
>> + pml_idx = 0;
>> + else
>> + pml_idx++;
>> +
>> + for ( ; pml_idx < PML_ENTITY_NUM; pml_idx++ )
>> + {
>> + struct p2m_domain *p2m = p2m_get_hostp2m(v->domain);
>> + unsigned long gfn;
>> + mfn_t mfn;
>> + p2m_type_t t;
>> + p2m_access_t a;
>> +
>> + gfn = pml_buf[pml_idx] >> PAGE_SHIFT;
>> + mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL);
> Please don't call p2m->get_entry() directly -- that interface should
> only be used inside the p2m code. As it happens, I don't think this
> lookup is correct anyway: the logging only sees races (which are not
> interesting) or buggy hardware (which is not worth the extra lookup to
> detect).
>
> So you only need this to get 'mfn' to pass to paging_mark_dirty().
True.
> That's also buggy, because there's no locking here to make sure
> gfn->mfn->gfn ends up in the right place. :(
Yes you are right. Thanks for pointing out.
Just curious, looks if I use get_gfn_type_access and put_gfn here, the
gfn->mfn->gfn can be guaranteed, and it's safe to use them here, right?
>
> I think the right thing to do is:
>
> - split paging_park_dirty() into paging_mark_gfn_dirty() (the bulk of
> the current function) and a paging_mark_dirty() wrapper that does
> get_gpfn_from_mfn(mfn_x(gmfn)) and calls paging_mark_gfn_dirty().
>
> - call paging_mark_gfn_dirty() from vmx_vcpu_flush_pml_buffer().
>
> That will avoid _two_ p2m lookups in this function. :)
Yours is indeed much better! Will do in this way.
Thanks,
-Kai
>
> Cheers,
>
> Tim.
next prev parent reply other threads:[~2015-04-10 7:05 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 2:35 [PATCH 00/10] PML (Paging Modification Logging) support Kai Huang
2015-03-27 2:35 ` [PATCH 01/10] VMX: Enable EPT A/D bit support Kai Huang
2015-03-27 20:38 ` Andrew Cooper
2015-03-30 6:11 ` Kai Huang
2015-03-30 9:36 ` Andrew Cooper
2015-03-30 13:35 ` Kai Huang
2015-03-30 13:39 ` Andrew Cooper
2015-04-02 6:32 ` Kai Huang
2015-04-02 9:55 ` Andrew Cooper
2015-04-09 11:21 ` Tim Deegan
2015-04-10 6:40 ` Kai Huang
2015-04-10 8:54 ` Tim Deegan
2015-04-10 9:26 ` Kai Huang
2015-04-10 9:51 ` Tim Deegan
2015-04-10 13:14 ` Kai Huang
2015-03-27 2:35 ` [PATCH 02/10] VMX: New parameter to control PML enabling Kai Huang
2015-03-27 20:42 ` Andrew Cooper
2015-03-30 6:16 ` Kai Huang
2015-04-02 5:46 ` Kai Huang
2015-04-02 9:58 ` Andrew Cooper
2015-04-02 13:34 ` Kai Huang
2015-03-27 2:35 ` [PATCH 03/10] VMX: Add PML definition and feature detection Kai Huang
2015-03-27 20:46 ` Andrew Cooper
2015-03-30 6:18 ` Kai Huang
2015-03-27 2:35 ` [PATCH 04/10] VMX: New data structure member to support PML Kai Huang
2015-03-27 20:48 ` Andrew Cooper
2015-03-30 6:19 ` Kai Huang
2015-03-27 2:35 ` [PATCH 05/10] VMX: add help functions " Kai Huang
2015-03-27 21:09 ` Andrew Cooper
2015-03-30 6:43 ` Kai Huang
2015-03-30 9:54 ` Andrew Cooper
2015-03-30 13:40 ` Kai Huang
2015-04-09 12:00 ` Tim Deegan
2015-04-10 7:05 ` Kai Huang [this message]
2015-04-10 9:03 ` Tim Deegan
2015-04-10 9:28 ` Kai Huang
2015-04-09 12:31 ` Tim Deegan
2015-04-10 7:07 ` Kai Huang
2015-03-27 2:35 ` [PATCH 06/10] VMX: handle PML buffer full VMEXIT Kai Huang
2015-03-27 2:35 ` [PATCH 07/10] VMX: handle PML enabling in vmx_vcpu_initialise Kai Huang
2015-03-27 21:12 ` Andrew Cooper
2015-03-30 7:03 ` Kai Huang
2015-03-30 10:00 ` Andrew Cooper
2015-03-27 2:35 ` [PATCH 08/10] VMX: disable PML in vmx_vcpu_destroy Kai Huang
2015-04-09 12:04 ` Tim Deegan
2015-04-10 7:25 ` Kai Huang
2015-04-10 9:30 ` Tim Deegan
2015-03-27 2:35 ` [PATCH 09/10] log-dirty: Refine common code to support PML Kai Huang
2015-04-09 12:27 ` Tim Deegan
2015-04-10 7:38 ` Kai Huang
2015-04-10 9:31 ` Tim Deegan
2015-04-10 9:33 ` Kai Huang
2015-03-27 2:35 ` [PATCH 10/10] p2m/ept: Enable PML in p2m-ept for log-dirty Kai Huang
2015-04-09 12:20 ` Tim Deegan
2015-04-10 8:44 ` Kai Huang
2015-04-10 9:46 ` Tim Deegan
2015-04-10 13:18 ` Kai Huang
2015-04-10 14:35 ` Tim Deegan
2015-03-27 21:26 ` [PATCH 00/10] PML (Paging Modification Logging) support Andrew Cooper
2015-03-30 5:50 ` Kai Huang
2015-04-07 8:30 ` Kai Huang
2015-04-07 9:24 ` Tim Deegan
2015-04-08 2:23 ` Kai Huang
2015-04-09 12:32 ` Tim Deegan
2015-04-10 6:40 ` Kai Huang
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=5527764A.506@linux.intel.com \
--to=kai.huang@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.