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

Re: [Xen-devel] [PATCH v2 09/12] x86/altp2m: add remaining support routines.





On Mon, Jun 22, 2015 at 2:56 PM, Ed White <edmund.h.white@xxxxxxxxx> wrote:
Add the remaining routines required to support enabling the alternate
p2m functionality.

Signed-off-by: Ed White <edmund.h.white@xxxxxxxxx>
---
Âxen/arch/x86/hvm/hvm.c       | 60 +++++-
Âxen/arch/x86/mm/hap/Makefile    | Â1 +
Âxen/arch/x86/mm/hap/altp2m_hap.c  | 103 +++++++++
Âxen/arch/x86/mm/p2m-ept.c     Â| Â3 +
Âxen/arch/x86/mm/p2m.c       Â| 405 ++++++++++++++++++++++++++++++++++++
Âxen/include/asm-x86/hvm/altp2mhvm.h |Â Â4 +
Âxen/include/asm-x86/p2m.h     Â| 33 +++
Â7 files changed, 601 insertions(+), 8 deletions(-)
Âcreate mode 100644 xen/arch/x86/mm/hap/altp2m_hap.c

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index d75c12d..b758ee1 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2786,10 +2786,11 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
  Âp2m_access_t p2ma;
  Âmfn_t mfn;
  Âstruct vcpu *v = current;
-Â Â struct p2m_domain *p2m;
+Â Â struct p2m_domain *p2m, *hostp2m;
  Âint rc, fall_through = 0, paged = 0;
  Âint sharing_enomem = 0;
  Âvm_event_request_t *req_ptr = NULL;
+Â Â int altp2m_active = 0;

  Â/* On Nested Virtualization, walk the guest page table.
   * If this succeeds, all is fine.
@@ -2845,15 +2846,33 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
  Â{
    Âif ( !handle_mmio_with_translation(gla, gpa >> PAGE_SHIFT, npfec) )
      Âhvm_inject_hw_exception(TRAP_gp_fault, 0);
-Â Â Â Â rc = 1;
-Â Â Â Â goto out;
+Â Â Â Â return 1;
  Â}

-Â Â p2m = p2m_get_hostp2m(v->domain);
-Â Â mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma,
+Â Â altp2m_active = altp2mhvm_active(v->domain);
+
+Â Â /* Take a lock on the host p2m speculatively, to avoid potential
+Â Â Â* locking order problems later and to handle unshare etc.
+Â Â Â*/
+Â Â hostp2m = p2m_get_hostp2m(v->domain);
+Â Â mfn = get_gfn_type_access(hostp2m, gfn, &p2mt, &p2ma,
               ÂP2M_ALLOC | (npfec.write_access ? P2M_UNSHARE : 0),
               ÂNULL);

+Â Â if ( altp2m_active )
+Â Â {
+Â Â Â Â if ( altp2mhvm_hap_nested_page_fault(v, gpa, gla, npfec, &p2m) == 1 )
+Â Â Â Â {
+Â Â Â Â Â Â /* entry was lazily copied from host -- retry */
+Â Â Â Â Â Â __put_gfn(hostp2m, gfn);
+Â Â Â Â Â Â return 1;
+Â Â Â Â }
+
+Â Â Â Â mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL);
+Â Â }
+Â Â else
+Â Â Â Â p2m = hostp2m;
+
  Â/* Check access permissions first, then handle faults */
  Âif ( mfn_x(mfn) != INVALID_MFN )
  Â{
@@ -2893,6 +2912,20 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,

    Âif ( violation )
    Â{
+Â Â Â Â Â Â /* Should #VE be emulated for this fault? */
+Â Â Â Â Â Â if ( p2m_is_altp2m(p2m) && !cpu_has_vmx_virt_exceptions )
+Â Â Â Â Â Â {
+Â Â Â Â Â Â Â Â unsigned int sve;
+
+Â Â Â Â Â Â Â Â p2m->get_entry_full(p2m, gfn, &p2mt, &p2ma, 0, NULL, &sve);
+
+Â Â Â Â Â Â Â Â if ( !sve && ahvm_vcpu_emulate_ve(v) )

This line generates the following compile-time error: "hvm.c:2923:51: error: âvâ undeclared (first use in this function)". Did you mean to pass curr to ahvm_vcpu_emulate_ve instead of v?

I would recommend doing a compile-test on each patch of the series to catch small things like this. Travis-ci has been working really great for me to automate that process (https://github.com/tklengyel/xen/compare/travis) ;)

--

www.novetta.com

Tamas K Lengyel

Senior Security Researcher


7921 Jones Branch Drive

McLean VA 22102

Email Âtlengyel@novetta.com

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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