diff mbox

[v5,18/23] x86/mm: export some stuff via local mm.h

Message ID 20170914125852.22129-19-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Sept. 14, 2017, 12:58 p.m. UTC
They will be used by PV mm code and mm hypercall code, which is going
to be split into two files.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/mm.c    | 30 +++++++++++-------------------
 xen/arch/x86/pv/mm.h | 21 +++++++++++++++++++++
 2 files changed, 32 insertions(+), 19 deletions(-)

Comments

Jan Beulich Sept. 22, 2017, 3:44 p.m. UTC | #1
>>> On 14.09.17 at 14:58, <wei.liu2@citrix.com> wrote:
> They will be used by PV mm code and mm hypercall code, which is going
> to be split into two files.

Hmm, no, I think I'd prefer mod_lN_entry() and
{get,put}_page_from_lNe() to stay in the same file (with the
possible exception of {get,put}_page_from_l1e(), as under
discussion elsewhere).

Jan
Wei Liu Sept. 22, 2017, 3:56 p.m. UTC | #2
On Fri, Sep 22, 2017 at 09:44:53AM -0600, Jan Beulich wrote:
> >>> On 14.09.17 at 14:58, <wei.liu2@citrix.com> wrote:
> > They will be used by PV mm code and mm hypercall code, which is going
> > to be split into two files.
> 
> Hmm, no, I think I'd prefer mod_lN_entry() and
> {get,put}_page_from_lNe() to stay in the same file (with the
> possible exception of {get,put}_page_from_l1e(), as under
> discussion elsewhere).
> 

Seeing that mod_lN_entry's are only used by PV hypercall code I opted to
split them to mm-hypercalls.c in later file.

Now you want to put {get,put}_page_from_lNe and mod_lN_entry in the same
file, there are two choices:

1. Merge mm-hypercalls.c into pv/mm.c.
2. Leave mod_*_entry in pv/mm.c and keep mm-hypercalls.c -- this would
   require exporting mod_*_entry via local header file.

Which one do you prefer?
Jan Beulich Sept. 22, 2017, 4 p.m. UTC | #3
>>> On 22.09.17 at 17:56, <wei.liu2@citrix.com> wrote:
> On Fri, Sep 22, 2017 at 09:44:53AM -0600, Jan Beulich wrote:
>> >>> On 14.09.17 at 14:58, <wei.liu2@citrix.com> wrote:
>> > They will be used by PV mm code and mm hypercall code, which is going
>> > to be split into two files.
>> 
>> Hmm, no, I think I'd prefer mod_lN_entry() and
>> {get,put}_page_from_lNe() to stay in the same file (with the
>> possible exception of {get,put}_page_from_l1e(), as under
>> discussion elsewhere).
>> 
> 
> Seeing that mod_lN_entry's are only used by PV hypercall code I opted to
> split them to mm-hypercalls.c in later file.
> 
> Now you want to put {get,put}_page_from_lNe and mod_lN_entry in the same
> file, there are two choices:
> 
> 1. Merge mm-hypercalls.c into pv/mm.c.
> 2. Leave mod_*_entry in pv/mm.c and keep mm-hypercalls.c -- this would
>    require exporting mod_*_entry via local header file.
> 
> Which one do you prefer?

I think I'd prefer 1 over 2, but please give Andrew a chance to
voice his opinion too.

Jan
Wei Liu Sept. 22, 2017, 4:07 p.m. UTC | #4
On Fri, Sep 22, 2017 at 10:00:20AM -0600, Jan Beulich wrote:
> >>> On 22.09.17 at 17:56, <wei.liu2@citrix.com> wrote:
> > On Fri, Sep 22, 2017 at 09:44:53AM -0600, Jan Beulich wrote:
> >> >>> On 14.09.17 at 14:58, <wei.liu2@citrix.com> wrote:
> >> > They will be used by PV mm code and mm hypercall code, which is going
> >> > to be split into two files.
> >> 
> >> Hmm, no, I think I'd prefer mod_lN_entry() and
> >> {get,put}_page_from_lNe() to stay in the same file (with the
> >> possible exception of {get,put}_page_from_l1e(), as under
> >> discussion elsewhere).
> >> 
> > 
> > Seeing that mod_lN_entry's are only used by PV hypercall code I opted to
> > split them to mm-hypercalls.c in later file.
> > 
> > Now you want to put {get,put}_page_from_lNe and mod_lN_entry in the same
> > file, there are two choices:
> > 
> > 1. Merge mm-hypercalls.c into pv/mm.c.
> > 2. Leave mod_*_entry in pv/mm.c and keep mm-hypercalls.c -- this would
> >    require exporting mod_*_entry via local header file.
> > 
> > Which one do you prefer?
> 
> I think I'd prefer 1 over 2, but please give Andrew a chance to
> voice his opinion too.
> 

Definitely.
Andrew Cooper Sept. 22, 2017, 4:09 p.m. UTC | #5
On 22/09/17 17:07, Wei Liu wrote:
> On Fri, Sep 22, 2017 at 10:00:20AM -0600, Jan Beulich wrote:
>>>>> On 22.09.17 at 17:56, <wei.liu2@citrix.com> wrote:
>>> On Fri, Sep 22, 2017 at 09:44:53AM -0600, Jan Beulich wrote:
>>>>>>> On 14.09.17 at 14:58, <wei.liu2@citrix.com> wrote:
>>>>> They will be used by PV mm code and mm hypercall code, which is going
>>>>> to be split into two files.
>>>> Hmm, no, I think I'd prefer mod_lN_entry() and
>>>> {get,put}_page_from_lNe() to stay in the same file (with the
>>>> possible exception of {get,put}_page_from_l1e(), as under
>>>> discussion elsewhere).
>>>>
>>> Seeing that mod_lN_entry's are only used by PV hypercall code I opted to
>>> split them to mm-hypercalls.c in later file.
>>>
>>> Now you want to put {get,put}_page_from_lNe and mod_lN_entry in the same
>>> file, there are two choices:
>>>
>>> 1. Merge mm-hypercalls.c into pv/mm.c.
>>> 2. Leave mod_*_entry in pv/mm.c and keep mm-hypercalls.c -- this would
>>>     require exporting mod_*_entry via local header file.
>>>
>>> Which one do you prefer?
>> I think I'd prefer 1 over 2, but please give Andrew a chance to
>> voice his opinion too.
>>
> Definitely.

I'd err on the side of 1) over 2) in this case.  I think it is more 
important to not have these functions exported, than to minimize the 
size of each translation unit.

~Andrew
diff mbox

Patch

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index e11aac3b90..f9cc5a0f6f 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -154,13 +154,6 @@  struct rangeset *__read_mostly mmio_ro_ranges;
 
 uint32_t __read_mostly base_disallow_mask;
 
-#define L2_DISALLOW_MASK base_disallow_mask
-
-#define l3_disallow_mask(d) (!is_pv_32bit_domain(d) ? \
-                             base_disallow_mask : 0xFFFFF198U)
-
-#define L4_DISALLOW_MASK (base_disallow_mask)
-
 static s8 __read_mostly opt_mmio_relax;
 
 static int __init parse_mmio_relax(const char *s)
@@ -545,9 +538,8 @@  static int alloc_segdesc_page(struct page_info *page)
     return i == 512 ? 0 : -EINVAL;
 }
 
-static int get_page_and_type_from_mfn(
-    mfn_t mfn, unsigned long type, struct domain *d,
-    int partial, int preemptible)
+int get_page_and_type_from_mfn(mfn_t mfn, unsigned long type, struct domain *d,
+                               int partial, int preemptible)
 {
     struct page_info *page = mfn_to_page(mfn);
     int rc;
@@ -930,7 +922,7 @@  get_page_from_l1e(
  *  <0 => error code
  */
 define_get_linear_pagetable(l2);
-static int
+int
 get_page_from_l2e(
     l2_pgentry_t l2e, unsigned long pfn, struct domain *d)
 {
@@ -966,7 +958,7 @@  get_page_from_l2e(
  *  <0 => error code
  */
 define_get_linear_pagetable(l3);
-static int
+int
 get_page_from_l3e(
     l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int partial)
 {
@@ -999,7 +991,7 @@  get_page_from_l3e(
  *  <0 => error code
  */
 define_get_linear_pagetable(l4);
-static int
+int
 get_page_from_l4e(
     l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int partial)
 {
@@ -1087,7 +1079,7 @@  void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner)
  * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'.
  * Note also that this automatically deals correctly with linear p.t.'s.
  */
-static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
+int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
 {
     if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || (l2e_get_pfn(l2e) == pfn) )
         return 1;
@@ -1105,8 +1097,8 @@  static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
     return 0;
 }
 
-static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn,
-                             int partial, bool defer)
+int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial,
+                      bool defer)
 {
     struct page_info *pg;
 
@@ -1143,8 +1135,8 @@  static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn,
     return put_page_and_type_preemptible(pg);
 }
 
-static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn,
-                             int partial, bool defer)
+int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, int partial,
+                      bool defer)
 {
     if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) &&
          (l4e_get_pfn(l4e) != pfn) )
@@ -1206,7 +1198,7 @@  static int alloc_l1_table(struct page_info *page)
     return ret;
 }
 
-static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e)
+int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e)
 {
     struct page_info *page;
     l3_pgentry_t     l3e3;
diff --git a/xen/arch/x86/pv/mm.h b/xen/arch/x86/pv/mm.h
index 43e797f201..b4bb214d95 100644
--- a/xen/arch/x86/pv/mm.h
+++ b/xen/arch/x86/pv/mm.h
@@ -1,6 +1,13 @@ 
 #ifndef __PV_MM_H__
 #define __PV_MM_H__
 
+#define L2_DISALLOW_MASK base_disallow_mask
+
+#define l3_disallow_mask(d) (!is_pv_32bit_domain(d) ? \
+                             base_disallow_mask : 0xFFFFF198U)
+
+#define L4_DISALLOW_MASK (base_disallow_mask)
+
 l1_pgentry_t *map_guest_l1e(unsigned long linear, mfn_t *gl1mfn);
 
 void init_guest_l4_table(l4_pgentry_t l4tab[], const struct domain *d,
@@ -8,6 +15,8 @@  void init_guest_l4_table(l4_pgentry_t l4tab[], const struct domain *d,
 
 int new_guest_cr3(mfn_t mfn);
 
+int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e);
+
 /* Read a PV guest's l1e that maps this linear address. */
 static inline l1_pgentry_t guest_get_eff_l1e(unsigned long linear)
 {
@@ -152,4 +161,16 @@  static inline l4_pgentry_t adjust_guest_l4e(l4_pgentry_t l4e,
     return l4e;
 }
 
+int get_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn, struct domain *d);
+int get_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, struct domain *d,
+                      int partial);
+int get_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, struct domain *d,
+                      int partial);
+int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn);
+int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial,
+                      bool defer);
+int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, int partial,
+                      bool defer);
+int get_page_and_type_from_mfn(mfn_t mfn, unsigned long type, struct domain *d,
+                               int partial, int preemptible);
 #endif /* __PV_MM_H__ */