All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Varad Gautam <vrd@amazon.de>,
	Ian Jackson <Ian.Jackson@citrix.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [Xen-devel] [PATCH 1/4] tools/dombuilder: xc_dom_x86 cleanup
Date: Tue, 17 Dec 2019 20:15:47 +0000	[thread overview]
Message-ID: <20191217201550.15864-2-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20191217201550.15864-1-andrew.cooper3@citrix.com>

The two xc_dom_params structures for PV pagetables are never modified and can
live in .rodata.  Reduce their scope to the alloc_pgtable_*() functions which
construct xc_dom_image_x86 appropriately.

Rename {alloc,setup}_pgtables() to {alloc,setup}_pgtables_pv() to highlight
that they are PV only, and drop some _x86() suffixes from static helpers.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Varad Gautam <vrd@amazon.de>
---
 tools/libxc/xc_dom_x86.c | 60 ++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 32 deletions(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 9e279d6768..1ce3c798ef 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -103,7 +103,7 @@ struct xc_dom_image_x86 {
     unsigned n_mappings;
 #define MAPPING_MAX 2
     struct xc_dom_x86_mapping maps[MAPPING_MAX];
-    struct xc_dom_params *params;
+    const struct xc_dom_params *params;
 };
 
 /* get guest IO ABI protocol */
@@ -235,7 +235,7 @@ static int count_pgtables(struct xc_dom_image *dom, xen_vaddr_t from,
     return 0;
 }
 
-static int alloc_pgtables(struct xc_dom_image *dom)
+static int alloc_pgtables_pv(struct xc_dom_image *dom)
 {
     int pages, extra_pages;
     xen_vaddr_t try_virt_end;
@@ -268,20 +268,20 @@ static int alloc_pgtables(struct xc_dom_image *dom)
 /* ------------------------------------------------------------------------ */
 /* i386 pagetables                                                          */
 
-static struct xc_dom_params x86_32_params = {
-    .levels = PGTBL_LEVELS_I386,
-    .vaddr_mask = bits_to_mask(VIRT_BITS_I386),
-    .lvl_prot[0] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED,
-    .lvl_prot[1] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-    .lvl_prot[2] = _PAGE_PRESENT,
-};
-
 static int alloc_pgtables_x86_32_pae(struct xc_dom_image *dom)
 {
+    static const struct xc_dom_params x86_32_params = {
+        .levels = PGTBL_LEVELS_I386,
+        .vaddr_mask = bits_to_mask(VIRT_BITS_I386),
+        .lvl_prot[0] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED,
+        .lvl_prot[1] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
+        .lvl_prot[2] = _PAGE_PRESENT,
+    };
     struct xc_dom_image_x86 *domx86 = dom->arch_private;
 
     domx86->params = &x86_32_params;
-    return alloc_pgtables(dom);
+
+    return alloc_pgtables_pv(dom);
 }
 
 #define pfn_to_paddr(pfn) ((xen_paddr_t)(pfn) << PAGE_SHIFT_X86)
@@ -355,7 +355,7 @@ static xen_pfn_t move_l3_below_4G(struct xc_dom_image *dom,
     return l3mfn;
 }
 
-static x86_pgentry_t *get_pg_table_x86(struct xc_dom_image *dom, int m, int l)
+static x86_pgentry_t *get_pg_table(struct xc_dom_image *dom, int m, int l)
 {
     struct xc_dom_image_x86 *domx86 = dom->arch_private;
     struct xc_dom_x86_mapping *map;
@@ -371,8 +371,7 @@ static x86_pgentry_t *get_pg_table_x86(struct xc_dom_image *dom, int m, int l)
     return NULL;
 }
 
-static x86_pgentry_t get_pg_prot_x86(struct xc_dom_image *dom, int l,
-                                     xen_pfn_t pfn)
+static x86_pgentry_t get_pg_prot(struct xc_dom_image *dom, int l, xen_pfn_t pfn)
 {
     struct xc_dom_image_x86 *domx86 = dom->arch_private;
     struct xc_dom_x86_mapping *map;
@@ -396,7 +395,7 @@ static x86_pgentry_t get_pg_prot_x86(struct xc_dom_image *dom, int l,
     return prot;
 }
 
-static int setup_pgtables_x86(struct xc_dom_image *dom)
+static int setup_pgtables_pv(struct xc_dom_image *dom)
 {
     struct xc_dom_image_x86 *domx86 = dom->arch_private;
     struct xc_dom_x86_mapping *map1, *map2;
@@ -413,7 +412,7 @@ static int setup_pgtables_x86(struct xc_dom_image *dom)
             map1 = domx86->maps + m1;
             from = map1->lvls[l].from;
             to = map1->lvls[l].to;
-            pg = get_pg_table_x86(dom, m1, l);
+            pg = get_pg_table(dom, m1, l);
             if ( !pg )
                 return -1;
             for ( m2 = 0; m2 < domx86->n_mappings; m2++ )
@@ -433,7 +432,7 @@ static int setup_pgtables_x86(struct xc_dom_image *dom)
                 for ( p = p_s; p <= p_e; p++ )
                 {
                     pg[p] = pfn_to_paddr(xc_dom_p2m(dom, pfn)) |
-                            get_pg_prot_x86(dom, l, pfn);
+                            get_pg_prot(dom, l, pfn);
                     pfn++;
                 }
             }
@@ -464,32 +463,32 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom)
         }
     }
 
-    return setup_pgtables_x86(dom);
+    return setup_pgtables_pv(dom);
 }
 
 /* ------------------------------------------------------------------------ */
 /* x86_64 pagetables                                                        */
 
-static struct xc_dom_params x86_64_params = {
-    .levels = PGTBL_LEVELS_X86_64,
-    .vaddr_mask = bits_to_mask(VIRT_BITS_X86_64),
-    .lvl_prot[0] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED,
-    .lvl_prot[1] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-    .lvl_prot[2] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-    .lvl_prot[3] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-};
-
 static int alloc_pgtables_x86_64(struct xc_dom_image *dom)
 {
+    const static struct xc_dom_params x86_64_params = {
+        .levels = PGTBL_LEVELS_X86_64,
+        .vaddr_mask = bits_to_mask(VIRT_BITS_X86_64),
+        .lvl_prot[0] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED,
+        .lvl_prot[1] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
+        .lvl_prot[2] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
+        .lvl_prot[3] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
+    };
     struct xc_dom_image_x86 *domx86 = dom->arch_private;
 
     domx86->params = &x86_64_params;
-    return alloc_pgtables(dom);
+
+    return alloc_pgtables_pv(dom);
 }
 
 static int setup_pgtables_x86_64(struct xc_dom_image *dom)
 {
-    return setup_pgtables_x86(dom);
+    return setup_pgtables_pv(dom);
 }
 
 /* ------------------------------------------------------------------------ */
@@ -1908,9 +1907,6 @@ static struct xc_dom_arch xc_hvm_32 = {
     .sizeof_pfn = 4,
     .alloc_magic_pages = alloc_magic_pages_hvm,
     .alloc_pgtables = alloc_pgtables_hvm,
-    .setup_pgtables = NULL,
-    .start_info = NULL,
-    .shared_info = NULL,
     .vcpu = vcpu_hvm,
     .meminit = meminit_hvm,
     .bootearly = bootearly,
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-12-17 20:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 20:15 [Xen-devel] [PATCH 0/4] Don't allocate dom->p2m_host[] for translated domains Andrew Cooper
2019-12-17 20:15 ` Andrew Cooper [this message]
2019-12-17 20:15 ` [Xen-devel] [PATCH 2/4] tools/dombuilder: Remove PV-only, mandatory hooks Andrew Cooper
2019-12-23 18:12   ` Julien Grall
2019-12-17 20:15 ` [Xen-devel] [PATCH 3/4] tools/dombuilder: Remove p2m_guest from the common interface Andrew Cooper
2019-12-17 20:15 ` [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains Andrew Cooper
2019-12-23 18:23   ` Julien Grall
2020-01-02 17:49     ` Andrew Cooper
2020-01-03 10:44       ` Julien Grall
2020-01-08  9:36         ` Julien Grall
2020-01-03 14:25   ` Jan Beulich
2020-01-03 15:02     ` Andrew Cooper
2020-01-03 15:33       ` Jan Beulich
2019-12-31 16:37 ` [Xen-devel] [PATCH 0/4] " Wei Liu

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=20191217201550.15864-2-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=vrd@amazon.de \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.