All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Razvan Cojocaru <rcojocaru@bitdefender.com>
Cc: kevin.tian@intel.com, ian.campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
	eddie.dong@intel.com, xen-devel@lists.xen.org,
	jun.nakajima@intel.com, ian.jackson@eu.citrix.com
Subject: Re: [PATCH RFC V6 4/5] xen, libxc: Request page fault injection via libxc
Date: Tue, 12 Aug 2014 16:16:52 +0100	[thread overview]
Message-ID: <53EA4C04020000780002BB71@mail.emea.novell.com> (raw)
In-Reply-To: <1407769686-7918-4-git-send-email-rcojocaru@bitdefender.com>

>>> On 11.08.14 at 17:08, <rcojocaru@bitdefender.com> wrote:
> +static bool_t vmx_check_pf_injection(void)
> +{
> +    struct vcpu *curr = current;
> +    const struct domain *currd = curr->domain;
> +    struct segment_register seg;
> +    unsigned long ev;
> +    uint32_t pending_event = 0;
> +    uint64_t mask;
> +
> +    if ( !is_hvm_domain(currd) ||
> +         likely(!currd->arch.hvm_domain.fault_info.valid) )
> +        return 0;
> +
> +    vmx_get_segment_register(curr, x86_seg_ss, &seg);
> +
> +    if ( seg.attr.fields.dpl != 3 ) /* Guest is not in user mode */
> +        return 0;
> +
> +    if ( hvm_long_mode_enabled(curr) )
> +        mask = 0x000ffffffffff000; /* Bits 51:12. */

PADDR_MASK & PAGE_MASK

> +    else if ( hvm_pae_enabled(curr) )
> +        mask = 0x00000000ffffffe0; /* Bits 31:5. */
> +    else
> +        mask = 0x00000000fffff000; /* Bits 31:12. */

And this would probably also better be (uint32_t)PAGE_MASK.

> +
> +    if ( (curr->arch.hvm_vcpu.guest_cr[3] & mask) !=
> +         (currd->arch.hvm_domain.fault_info.address_space & mask) )
> +        return 0;
> +
> +    vmx_vmcs_enter(curr);
> +    __vmread(VM_ENTRY_INTR_INFO, &ev);
> +
> +    if ( (ev & INTR_INFO_VALID_MASK) &&
> +         hvm_event_needs_reinjection(MASK_EXTR(ev, INTR_INFO_INTR_TYPE_MASK),
> +                                     ev & INTR_INFO_VECTOR_MASK) )
> +        pending_event = ev;
> +
> +    vmx_vmcs_exit(curr);

Again - is there a reason not to move this right after the __vmread()
above?

> +    return pending_event == 0;
> +}
> +
> +static void vmx_inject_pf(void)
> +{
> +    struct vcpu *curr = current;
> +    struct domain *currd = curr->domain;
> +    int errcode = PFEC_user_mode;

unsigned

> +    uint64_t virtual_address = currd->arch.hvm_domain.fault_info.virtual_address;
> +
> +    currd->arch.hvm_domain.fault_info.valid = 0;
> +
> +    if ( currd->arch.hvm_domain.fault_info.write_access )
> +        errcode |= PFEC_write_access;

Isn't this pretty limited a set of error codes you're able to generate
here?

> --- a/xen/include/asm-x86/hvm/domain.h
> +++ b/xen/include/asm-x86/hvm/domain.h
> @@ -141,6 +141,14 @@ struct hvm_domain {
>       */
>      uint64_t sync_tsc;
>  
> +    /* Memory introspection page fault injection data. */
> +    struct {
> +        uint64_t address_space;
> +        uint64_t virtual_address;
> +        uint32_t write_access;

Is this meaningfully a 32-bit field (rather than just a boolean one)?

> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -937,6 +937,19 @@ typedef struct xen_domctl_vcpu_msrs xen_domctl_vcpu_msrs_t;
>  DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpu_msrs_t);
>  #endif
>  
> +/* XEN_DOMCTL_set_pagefault_info requests that a page fault occur at
> + * the next VMENTRY.
> + */

Coding style.

> +struct xen_domctl_set_pagefault_info {
> +    uint64_t address_space;
> +    uint64_t virtual_address;
> +    uint32_t write_access;

I guess you want this to be a fixed size one in the public interface,
but if only zero/non-zero counts, this could (a) be a uint8_t and
(b) get evaluated using the canonical !! when converting to the
internal structure.

Jan

  reply	other threads:[~2014-08-12 15:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11 15:08 [PATCH RFC V6 1/5] xen: Emulate with no writes Razvan Cojocaru
2014-08-11 15:08 ` [PATCH RFC V6 2/5] xen: Optimize introspection access to guest state Razvan Cojocaru
2014-08-12 15:01   ` Jan Beulich
2014-08-11 15:08 ` [PATCH RFC V6 3/5] xen, libxc: Force-enable relevant MSR events Razvan Cojocaru
2014-08-12 15:06   ` Jan Beulich
2014-08-12 15:09     ` Razvan Cojocaru
2014-08-11 15:08 ` [PATCH RFC V6 4/5] xen, libxc: Request page fault injection via libxc Razvan Cojocaru
2014-08-12 15:16   ` Jan Beulich [this message]
2014-08-12 15:42     ` Razvan Cojocaru
2014-08-12 16:03       ` Jan Beulich
2014-08-11 15:08 ` [PATCH RFC V6 5/5] xen: Handle resumed instruction based on previous mem_event reply Razvan Cojocaru
2014-08-12 15:20   ` Jan Beulich
2014-08-12 15:43     ` Razvan Cojocaru
2014-08-12 14:57 ` [PATCH RFC V6 1/5] xen: Emulate with no writes Jan Beulich
2014-08-12 15:08   ` Razvan Cojocaru
2014-08-12 15:27     ` Jan Beulich
2014-08-12 15:49       ` Razvan Cojocaru

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=53EA4C04020000780002BB71@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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 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.