]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
MPN to MPN 64 conversion for Hosted.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:27:44 +0000 (20:27 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:10:48 +0000 (22:10 -0700)
This change is supporting a 64bit MPN for hosted products.

Assumptions taken:

1. Kindly note that currently we do not have systems supporting 64bit
memory. So hosted vmmon 64 bit MPN is a container to store whatever
monitor passes to it.  The underlying assumption is that the higher
32bits will be zero.

2. Physmem tracker still does page walk using 32 bit values and we have
put checks to make sure that MPN64 is just a container with actually 32
bit values. This was a design decision taken after talking to kevinc and
jpool.

3. The CrossPage code is still 32 bit and I typecast MPN64 to accept 32
bit values for the crosspage code.

4. Vmkernel already has another definition of MPN64 and I have retained
their definition for vmkernel specific code.

typedef uint8 * MPN64;
typedef uint64 MPN64;

5. Additional changes were required in bora-vmsoft vmballoon module
which earlier used MPN and called functions expecting MPN64 as an input.
I have however *NOT* changed the PageHandle code of Vmballoon.  I have
typecasted to MPN64 where common MacOS page handling functions which
require MPN64 are used.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/include/vm_basic_types.h
open-vm-tools/modules/linux/vmci/shared/pgtbl.h
open-vm-tools/modules/shared/vmmemctl/os.h

index d3d14748da374a66f5b191a734d6b2dc46f454a1..b9786838148e2701287f904035f75f74098bbce9 100644 (file)
@@ -595,6 +595,17 @@ typedef void * UserVA;
 
 #if defined(VMKERNEL) || defined(VMKBOOT)
 #define INVALID_MPN64     ((MPN64)(uintptr_t)INVALID_MPN)
+#else
+/*
+ * We are zero extending the 32 bit MPN in a 64 bit MPN container
+ * This should change when we actually get a host supporting 64 bit
+ * memory/address space.
+ */
+
+#define INVALID_MPN64     ((MPN64)INVALID_MPN)
+#define RESERVED_MPN64    ((MPN64)RESERVED_MPN)
+#define MEMREF_MPN64      ((MPN64)MEMREF_MPN)
+#define RELEASED_MPN64    ((MPN64)RELEASED_MPN)
 #endif
 
 /*
index 0f0faee26cd9b9fdfa60031235faa47de6f6ea88..461ef4831272235ec52cadc4d05cc7ef00f1622d 100644 (file)
@@ -37,8 +37,8 @@
  *    holding a spinlock --hpreg
  *
  * Results:
- *    INVALID_MPN on failure
- *    mpn         on success
+ *    INVALID_MPN64 on failure
+ *    mpn           on success
  *
  * Side effects:
  *    None
  *-----------------------------------------------------------------------------
  */
 
-static INLINE MPN
+static INLINE MPN64
 PgtblPte2MPN(pte_t *pte)   // IN
 {
+   MPN64 mpn;
    if (pte_present(*pte) == 0) {
-      return INVALID_MPN;
+      return INVALID_MPN64;
    }
-   return pte_pfn(*pte);
+   mpn = pte_pfn(*pte);
+   if (mpn >= INVALID_MPN64) {
+      return INVALID_MPN64;
+   }
+   return mpn;
 }
 
 
@@ -167,12 +172,12 @@ PgtblVa2PTELocked(struct mm_struct *mm, // IN: Mm structure of a process
  *
  *    Retrieve MPN for a given va.
  *
- *    Caller must call pte_unmap if valid pte returned. The mm->page_table_lock 
+ *    Caller must call pte_unmap if valid pte returned. The mm->page_table_lock
  *    must be held, so this function is not allowed to schedule() --hpreg
  *
  * Results:
- *    INVALID_MPN on failure
- *    mpn         on success
+ *    INVALID_MPN64 on failure
+ *    mpn          on success
  *
  * Side effects:
  *    None
@@ -180,7 +185,7 @@ PgtblVa2PTELocked(struct mm_struct *mm, // IN: Mm structure of a process
  *-----------------------------------------------------------------------------
  */
 
-static INLINE MPN
+static INLINE MPN64
 PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
                   VA addr)              // IN: Address in the virtual address
 {
@@ -188,12 +193,12 @@ PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
 
    pte = PgtblVa2PTELocked(mm, addr);
    if (pte != NULL) {
-      MPN mpn = PgtblPte2MPN(pte);
+      MPN64 mpn = PgtblPte2MPN(pte);
       pte_unmap(pte);
       return mpn;
    }
-   return INVALID_MPN;
-} 
+   return INVALID_MPN64;
+}
 
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
@@ -208,8 +213,8 @@ PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
  *    must be held, so this function is not allowed to schedule() --hpreg
  *
  * Results:
- *    INVALID_MPN on failure
- *    mpn         on success
+ *    INVALID_MPN64 on failure
+ *    mpn           on success
  *
  * Side effects:
  *    None
@@ -217,7 +222,7 @@ PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
  *-----------------------------------------------------------------------------
  */
 
-static INLINE MPN
+static INLINE MPN64
 PgtblKVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a caller
                    VA addr)              // IN: Address in the virtual address
 {
@@ -225,11 +230,11 @@ PgtblKVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a caller
 
    pte = PgtblPGD2PTELocked(compat_pgd_offset_k(mm, addr), addr);
    if (pte != NULL) {
-      MPN mpn = PgtblPte2MPN(pte);
+      MPN64 mpn = PgtblPte2MPN(pte);
       pte_unmap(pte);
       return mpn;
    }
-   return INVALID_MPN;
+   return INVALID_MPN64;
 }
 #endif
 
@@ -285,11 +290,11 @@ PgtblVa2PageLocked(struct mm_struct *mm, // IN: Mm structure of a process
  *-----------------------------------------------------------------------------
  */
 
-static INLINE int
+static INLINE MPN64
 PgtblVa2MPN(VA addr)  // IN
 {
    struct mm_struct *mm;
-   MPN mpn;
+   MPN64 mpn;
 
    /* current->mm is NULL for kernel threads, so use active_mm. */
    mm = current->active_mm;
@@ -322,11 +327,11 @@ PgtblVa2MPN(VA addr)  // IN
  *-----------------------------------------------------------------------------
  */
 
-static INLINE int
+static INLINE MPN64
 PgtblKVa2MPN(VA addr)  // IN
 {
    struct mm_struct *mm = current->active_mm;
-   MPN mpn;
+   MPN64 mpn;
 
    if (compat_get_page_table_lock(mm)) {
       spin_lock(compat_get_page_table_lock(mm));
index 9ef96979277df62d39bd6e3b37231b993ca1e360..e8f1d48bbf7f3738cdd62b482341eef35d40740e 100644 (file)
 /*
  * Types
  */
-
+#if defined __APPLE__
+typedef uint64 PageHandle;
+#else
 typedef uintptr_t PageHandle;
+#endif
 typedef uintptr_t Mapping;
 
 #define PAGE_HANDLE_INVALID     0