All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH v4 0/2] xen/mm: address violatios of MISRA C:2012 Rules 8.2 and 8.3
@ 2023-11-22  9:51 Federico Serafini
  2023-11-22  9:51 ` [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces Federico Serafini
  2023-11-22  9:51 ` [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
  0 siblings, 2 replies; 7+ messages in thread
From: Federico Serafini @ 2023-11-22  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Federico Serafini, Jan Beulich, Andrew Cooper,
	Roger Pau Monné,
	Wei Liu, Stefano Stabellini, Julien Grall, Bertrand Marquis,
	Michal Orzel, Volodymyr Babchuk, George Dunlap, Shawn Anastasio

Patch 1/2 does some preparation work, hence it needs to be committed as first.
Patch 2/2 is the one that effectively address the violations adding
missing parameter names and uniforming function declarations and definitions.

Federico Serafini (2):
  x86/mm: preparation work to uniform modify_xen_mappings* interfaces
  xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3

 xen/arch/arm/mmu/pt.c   |  4 ++--
 xen/arch/ppc/mm-radix.c |  2 +-
 xen/arch/x86/mm.c       | 13 +++++++------
 xen/include/xen/mm.h    | 16 +++++++++-------
 4 files changed, 19 insertions(+), 16 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces
  2023-11-22  9:51 [XEN PATCH v4 0/2] xen/mm: address violatios of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
@ 2023-11-22  9:51 ` Federico Serafini
  2023-11-22 22:20   ` Stefano Stabellini
  2023-11-22  9:51 ` [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
  1 sibling, 1 reply; 7+ messages in thread
From: Federico Serafini @ 2023-11-22  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Federico Serafini, Jan Beulich, Andrew Cooper,
	Roger Pau Monné,
	Wei Liu

The objective is to use parameter name "nf" to denote "new flags"
in all the modify_xen_mappings* functions.
Since modify_xen_mappings_lite() is currently using "nf" as identifier
for a local variable, bad things could happen if new uses of such
variable are committed while a renaming patch is waiting for the
approval.
To avoid such danger, as first thing rename the local variable from
"nf" to "flags".

No functional change.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
 xen/arch/x86/mm.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 39544bd9f9..42c957c40e 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5903,15 +5903,15 @@ int destroy_xen_mappings(unsigned long s, unsigned long e)
 void init_or_livepatch modify_xen_mappings_lite(
     unsigned long s, unsigned long e, unsigned int _nf)
 {
-    unsigned long v = s, fm, nf;
+    unsigned long v = s, fm, flags;
 
     /* Set of valid PTE bits which may be altered. */
 #define FLAGS_MASK (_PAGE_NX|_PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_RW|_PAGE_PRESENT)
     fm = put_pte_flags(FLAGS_MASK);
-    nf = put_pte_flags(_nf & FLAGS_MASK);
+    flags = put_pte_flags(_nf & FLAGS_MASK);
 #undef FLAGS_MASK
 
-    ASSERT(nf & _PAGE_PRESENT);
+    ASSERT(flags & _PAGE_PRESENT);
     ASSERT(IS_ALIGNED(s, PAGE_SIZE) && s >= XEN_VIRT_START);
     ASSERT(IS_ALIGNED(e, PAGE_SIZE) && e <= XEN_VIRT_END);
 
@@ -5925,7 +5925,7 @@ void init_or_livepatch modify_xen_mappings_lite(
 
         if ( l2e_get_flags(l2e) & _PAGE_PSE )
         {
-            l2e_write_atomic(pl2e, l2e_from_intpte((l2e.l2 & ~fm) | nf));
+            l2e_write_atomic(pl2e, l2e_from_intpte((l2e.l2 & ~fm) | flags));
 
             v += 1UL << L2_PAGETABLE_SHIFT;
             continue;
@@ -5943,7 +5943,8 @@ void init_or_livepatch modify_xen_mappings_lite(
 
                 ASSERT(l1f & _PAGE_PRESENT);
 
-                l1e_write_atomic(pl1e, l1e_from_intpte((l1e.l1 & ~fm) | nf));
+                l1e_write_atomic(pl1e,
+                                 l1e_from_intpte((l1e.l1 & ~fm) | flags));
 
                 v += 1UL << L1_PAGETABLE_SHIFT;
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3
  2023-11-22  9:51 [XEN PATCH v4 0/2] xen/mm: address violatios of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
  2023-11-22  9:51 ` [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces Federico Serafini
@ 2023-11-22  9:51 ` Federico Serafini
  2023-11-22 22:22   ` Stefano Stabellini
  1 sibling, 1 reply; 7+ messages in thread
From: Federico Serafini @ 2023-11-22  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Federico Serafini, Stefano Stabellini, Julien Grall,
	Bertrand Marquis, Michal Orzel, Volodymyr Babchuk, Andrew Cooper,
	George Dunlap, Jan Beulich, Wei Liu, Shawn Anastasio,
	Roger Pau Monné

Add missing parameter names and uniform the interfaces of
modify_xen_mappings() and modify_xen_mappings_lite().

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
This patch depends on patch 1/2 of the same series.
---
 xen/arch/arm/mmu/pt.c   |  4 ++--
 xen/arch/ppc/mm-radix.c |  2 +-
 xen/arch/x86/mm.c       |  4 ++--
 xen/include/xen/mm.h    | 16 +++++++++-------
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/mmu/pt.c b/xen/arch/arm/mmu/pt.c
index e6fc5ed45a..a7755728ae 100644
--- a/xen/arch/arm/mmu/pt.c
+++ b/xen/arch/arm/mmu/pt.c
@@ -718,12 +718,12 @@ int destroy_xen_mappings(unsigned long s, unsigned long e)
     return xen_pt_update(s, INVALID_MFN, (e - s) >> PAGE_SHIFT, 0);
 }
 
-int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags)
+int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
 {
     ASSERT(IS_ALIGNED(s, PAGE_SIZE));
     ASSERT(IS_ALIGNED(e, PAGE_SIZE));
     ASSERT(s <= e);
-    return xen_pt_update(s, INVALID_MFN, (e - s) >> PAGE_SHIFT, flags);
+    return xen_pt_update(s, INVALID_MFN, (e - s) >> PAGE_SHIFT, nf);
 }
 
 /*
diff --git a/xen/arch/ppc/mm-radix.c b/xen/arch/ppc/mm-radix.c
index 11d0f27b60..daa411a6fa 100644
--- a/xen/arch/ppc/mm-radix.c
+++ b/xen/arch/ppc/mm-radix.c
@@ -271,7 +271,7 @@ void __init setup_initial_pagetables(void)
  */
 unsigned long __read_mostly frametable_base_pdx;
 
-void put_page(struct page_info *p)
+void put_page(struct page_info *page)
 {
     BUG_ON("unimplemented");
 }
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 42c957c40e..0a66db10b9 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5901,14 +5901,14 @@ int destroy_xen_mappings(unsigned long s, unsigned long e)
  * a problem.
  */
 void init_or_livepatch modify_xen_mappings_lite(
-    unsigned long s, unsigned long e, unsigned int _nf)
+    unsigned long s, unsigned long e, unsigned int nf)
 {
     unsigned long v = s, fm, flags;
 
     /* Set of valid PTE bits which may be altered. */
 #define FLAGS_MASK (_PAGE_NX|_PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_RW|_PAGE_PRESENT)
     fm = put_pte_flags(FLAGS_MASK);
-    flags = put_pte_flags(_nf & FLAGS_MASK);
+    flags = put_pte_flags(nf & FLAGS_MASK);
 #undef FLAGS_MASK
 
     ASSERT(flags & _PAGE_PRESENT);
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 8b9618609f..d0682c9da5 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -71,9 +71,10 @@
 
 struct page_info;
 
-void put_page(struct page_info *);
-bool __must_check get_page(struct page_info *, const struct domain *);
-struct domain *__must_check page_get_owner_and_reference(struct page_info *);
+void put_page(struct page_info *page);
+bool __must_check get_page(struct page_info *page,
+                           const struct domain *domain);
+struct domain *__must_check page_get_owner_and_reference(struct page_info *page);
 
 /* Boot-time allocator. Turns into generic allocator after bootstrap. */
 void init_boot_pages(paddr_t ps, paddr_t pe);
@@ -110,8 +111,9 @@ int map_pages_to_xen(
     unsigned long nr_mfns,
     unsigned int flags);
 /* Alter the permissions of a range of Xen virtual address space. */
-int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags);
-void modify_xen_mappings_lite(unsigned long s, unsigned long e, unsigned int flags);
+int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf);
+void modify_xen_mappings_lite(unsigned long s, unsigned long e,
+                              unsigned int nf);
 int destroy_xen_mappings(unsigned long s, unsigned long e);
 /* Retrieve the MFN mapped by VA in Xen virtual address space. */
 mfn_t xen_map_to_mfn(unsigned long va);
@@ -135,7 +137,7 @@ void free_domheap_pages(struct page_info *pg, unsigned int order);
 unsigned long avail_domheap_pages_region(
     unsigned int node, unsigned int min_width, unsigned int max_width);
 unsigned long avail_domheap_pages(void);
-unsigned long avail_node_heap_pages(unsigned int);
+unsigned long avail_node_heap_pages(unsigned int nodeid);
 #define alloc_domheap_page(d,f) (alloc_domheap_pages(d,0,f))
 #define free_domheap_page(p)  (free_domheap_pages(p,0))
 unsigned int online_page(mfn_t mfn, uint32_t *status);
@@ -528,7 +530,7 @@ static inline unsigned int get_order_from_pages(unsigned long nr_pages)
     return order;
 }
 
-void scrub_one_page(struct page_info *);
+void scrub_one_page(struct page_info *pg);
 
 #ifndef arch_free_heap_page
 #define arch_free_heap_page(d, pg) \
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces
  2023-11-22  9:51 ` [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces Federico Serafini
@ 2023-11-22 22:20   ` Stefano Stabellini
  2023-11-27 13:18     ` Jan Beulich
  0 siblings, 1 reply; 7+ messages in thread
From: Stefano Stabellini @ 2023-11-22 22:20 UTC (permalink / raw)
  To: Federico Serafini
  Cc: xen-devel, consulting, Jan Beulich, Andrew Cooper,
	Roger Pau Monné,
	Wei Liu

On Wed, 22 Nov 2023, Federico Serafini wrote:
> The objective is to use parameter name "nf" to denote "new flags"
> in all the modify_xen_mappings* functions.
> Since modify_xen_mappings_lite() is currently using "nf" as identifier
> for a local variable, bad things could happen if new uses of such
> variable are committed while a renaming patch is waiting for the
> approval.
> To avoid such danger, as first thing rename the local variable from
> "nf" to "flags".
> 
> No functional change.
> 
> Suggested-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3
  2023-11-22  9:51 ` [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
@ 2023-11-22 22:22   ` Stefano Stabellini
  2023-11-27 13:19     ` Jan Beulich
  0 siblings, 1 reply; 7+ messages in thread
From: Stefano Stabellini @ 2023-11-22 22:22 UTC (permalink / raw)
  To: Federico Serafini
  Cc: xen-devel, consulting, Stefano Stabellini, Julien Grall,
	Bertrand Marquis, Michal Orzel, Volodymyr Babchuk, Andrew Cooper,
	George Dunlap, Jan Beulich, Wei Liu, Shawn Anastasio,
	Roger Pau Monné

On Wed, 22 Nov 2023, Federico Serafini wrote:
> Add missing parameter names and uniform the interfaces of
> modify_xen_mappings() and modify_xen_mappings_lite().
> 
> No functional change.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces
  2023-11-22 22:20   ` Stefano Stabellini
@ 2023-11-27 13:18     ` Jan Beulich
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2023-11-27 13:18 UTC (permalink / raw)
  To: Federico Serafini
  Cc: xen-devel, consulting, Andrew Cooper, Roger Pau Monné,
	Wei Liu, Stefano Stabellini

On 22.11.2023 23:20, Stefano Stabellini wrote:
> On Wed, 22 Nov 2023, Federico Serafini wrote:
>> The objective is to use parameter name "nf" to denote "new flags"
>> in all the modify_xen_mappings* functions.
>> Since modify_xen_mappings_lite() is currently using "nf" as identifier
>> for a local variable, bad things could happen if new uses of such
>> variable are committed while a renaming patch is waiting for the
>> approval.
>> To avoid such danger, as first thing rename the local variable from
>> "nf" to "flags".
>>
>> No functional change.
>>
>> Suggested-by: Jan Beulich <jbeulich@suse.com>
>> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Jan Beulich <jbeulich@suse.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3
  2023-11-22 22:22   ` Stefano Stabellini
@ 2023-11-27 13:19     ` Jan Beulich
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2023-11-27 13:19 UTC (permalink / raw)
  To: Federico Serafini
  Cc: xen-devel, consulting, Julien Grall, Bertrand Marquis,
	Michal Orzel, Volodymyr Babchuk, Andrew Cooper, George Dunlap,
	Wei Liu, Shawn Anastasio, Roger Pau Monné,
	Stefano Stabellini

On 22.11.2023 23:22, Stefano Stabellini wrote:
> On Wed, 22 Nov 2023, Federico Serafini wrote:
>> Add missing parameter names and uniform the interfaces of
>> modify_xen_mappings() and modify_xen_mappings_lite().
>>
>> No functional change.
>>
>> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Jan Beulich <jbeulich@suse.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-27 13:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22  9:51 [XEN PATCH v4 0/2] xen/mm: address violatios of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
2023-11-22  9:51 ` [XEN PATCH v4 1/2] x86/mm: preparation work to uniform modify_xen_mappings* interfaces Federico Serafini
2023-11-22 22:20   ` Stefano Stabellini
2023-11-27 13:18     ` Jan Beulich
2023-11-22  9:51 ` [XEN PATCH v4 2/2] xen/mm: address violations of MISRA C:2012 Rules 8.2 and 8.3 Federico Serafini
2023-11-22 22:22   ` Stefano Stabellini
2023-11-27 13:19     ` Jan Beulich

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.