All of lore.kernel.org
 help / color / mirror / Atom feed
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 10/10] p2m/ept: Enable PML in p2m-ept for log-dirty.
Date: Fri, 10 Apr 2015 16:44:31 +0800	[thread overview]
Message-ID: <55278D6F.7020200@linux.intel.com> (raw)
In-Reply-To: <20150409122014.GH17031@deinos.phlegethon.org>



On 04/09/2015 08:20 PM, Tim Deegan wrote:
> At 10:35 +0800 on 27 Mar (1427452554), Kai Huang wrote:
>> @@ -118,6 +119,12 @@ static void ept_p2m_type_to_flags(ept_entry_t *entry, p2m_type_t type, p2m_acces
>>               break;
>>           case p2m_ram_rw:
>>               entry->r = entry->w = entry->x = 1;
>> +            /*
>> +             * This is about to avoid unnecessary GPA logging in PML buffer,
>> +             * such as normal memory in partial log-dirty
>> +             */
>> +            if ( vmx_domain_pml_enabled(p2m->domain) )
>> +                entry->d = 1;
> I think that both A and D should be set here, even when PML is not
> supported, to avoid the MMU having to write them later.  And indeed
> not just for ram_rw, but for every present leaf type.
I do agree we should also set A if PML is enabled for the domain, and 
looks there's no harm to set A bit for all present leaf types. Actually 
there should be no harm to set A bit even the leaf entry is not present..

But for D bit I think we should be more specific. For p2m types that are 
writable, we should set the D-bit to avoid unnecessary GPA logging, but 
for those are read-only, I think it's not reasonable to set D bit, as 
it's not possible for them to be dirty.

>
> You will still need to check whether the CPU supports the A/D bits,
> since AIUI those are reserved bits otherwise.
In my understanding, A/D bits actually are ignored if EPT A/D bit is not 
enabled in EPTP. Citing one statement in SDM for an example:

"If bit 6 of EPTP is 1, accessed flag for EPT; indicates whether 
software has accessed the 4-KByte page referenced
by this entry (see Section 28.2.4). Ignored if bit 6 of EPTP is 0".

Therefore I think it's unnecessary to check whether CPU supports A/D 
bits prior to setting A/D bits. The checking is an overhead anyway. And 
it reminds me we can safely set A bit in middle level entry in splitting 
super page case, which you pointed out in patch 1 to enable A/D bits.

Of course it's safer to operate A/D bits with whether cpu supports A/D 
bits checked, and we might better do it.

Is this reasonable?

Thanks,
-Kai
>
>>               break;
>>           case p2m_mmio_direct:
>>               entry->r = entry->x = 1;
>> @@ -125,6 +132,26 @@ static void ept_p2m_type_to_flags(ept_entry_t *entry, p2m_type_t type, p2m_acces
>>                                                       entry->mfn);
>>               break;
>>           case p2m_ram_logdirty:
>> +            entry->r = entry->x = 1;
>> +            if ( vmx_domain_pml_enabled(p2m->domain) )
>> +            {
>> +                /*
>> +                 * In case of PML, we don't have to write protect 4K page, but
>> +                 * only need to clear D-bit for it. Note we still need to write
>> +                 * protect super page in order to split it to 4K pages in EPT
>> +                 * violation.
>> +                 */
>> +                if ( !is_epte_superpage(entry) )
>> +                {
>> +                    entry->w = 1;
>> +                    entry->d = 0;
>> +                }
>> +                else
>> +                    entry->w = 0;
>> +            }
>> +            else
>> +                entry->w = 0;
>> +            break;
> This can be folded into a neater form:
>
>              if ( vmx_domain_pml_enabled(p2m->domain)
> 	         && !is_epte_superpage(entry) )
>              {
>                  /*
>                   * In case of PML, we don't have to write protect 4K page, but
>                   * only need to clear D-bit for it. Note we still need to write
>                   * protect super page in order to split it to 4K pages in EPT
>                   * violation.
>                   */
>                  entry->w = 1;
>                  entry->d = 0;
>              }
>              else
>                  entry->w = 0;
Sure.

Thanks,
-Kai
>
> Cheers,
>
> Tim.

  reply	other threads:[~2015-04-10  8:44 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
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 [this message]
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=55278D6F.7020200@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.