From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>
Subject: [PATCH 3/5] x86/p2m: suppress audit_p2m hook when possible
Date: Wed, 28 Oct 2020 10:23:42 +0100 [thread overview]
Message-ID: <722cf75e-da6a-49c5-472a-898796c9030e@suse.com> (raw)
In-Reply-To: <29d30de1-2a8d-aee2-d3c3-331758766fc9@suse.com>
When P2M_AUDIT is false, it's unused, so instead of having a dangling
NULL pointer sit there, omit the field altogether.
Instead of adding "#if P2M_AUDIT && defined(CONFIG_HVM)" in even more
places, fold the latter part right into the definition of P2M_AUDIT.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1012,7 +1012,7 @@ long arch_do_domctl(
break;
#endif
-#if P2M_AUDIT && defined(CONFIG_HVM)
+#if P2M_AUDIT
case XEN_DOMCTL_audit_p2m:
if ( d == currd )
ret = -EPERM;
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -1260,7 +1260,9 @@ int ept_p2m_init(struct p2m_domain *p2m)
p2m->change_entry_type_global = ept_change_entry_type_global;
p2m->change_entry_type_range = ept_change_entry_type_range;
p2m->memory_type_changed = ept_memory_type_changed;
+#if P2M_AUDIT
p2m->audit_p2m = NULL;
+#endif
p2m->tlb_flush = ept_tlb_flush;
/* Set the memory type used when accessing EPT paging structures. */
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -971,8 +971,8 @@ static int p2m_pt_change_entry_type_rang
return err;
}
-#if P2M_AUDIT && defined(CONFIG_HVM)
-long p2m_pt_audit_p2m(struct p2m_domain *p2m)
+#if P2M_AUDIT
+static long p2m_pt_audit_p2m(struct p2m_domain *p2m)
{
unsigned long entry_count = 0, pmbad = 0;
unsigned long mfn, gfn, m2pfn;
@@ -1120,8 +1120,6 @@ long p2m_pt_audit_p2m(struct p2m_domain
return pmbad;
}
-#else
-# define p2m_pt_audit_p2m NULL
#endif /* P2M_AUDIT */
/* Set up the p2m function pointers for pagetable format */
@@ -1141,8 +1139,6 @@ void p2m_pt_init(struct p2m_domain *p2m)
#if P2M_AUDIT
p2m->audit_p2m = p2m_pt_audit_p2m;
-#else
- p2m->audit_p2m = NULL;
#endif
}
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2435,7 +2435,7 @@ int p2m_altp2m_propagate_change(struct d
/*** Audit ***/
-#if P2M_AUDIT && defined(CONFIG_HVM)
+#if P2M_AUDIT
void audit_p2m(struct domain *d,
uint64_t *orphans,
uint64_t *m2p_bad,
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -31,6 +31,14 @@
#include <asm/mem_sharing.h>
#include <asm/page.h> /* for pagetable_t */
+/* Debugging and auditing of the P2M code? */
+#ifndef NDEBUG
+#define P2M_AUDIT defined(CONFIG_HVM)
+#else
+#define P2M_AUDIT 0
+#endif
+#define P2M_DEBUGGING 0
+
extern bool_t opt_hap_1gb, opt_hap_2mb;
/*
@@ -268,7 +276,9 @@ struct p2m_domain {
int (*write_p2m_entry)(struct p2m_domain *p2m,
unsigned long gfn, l1_pgentry_t *p,
l1_pgentry_t new, unsigned int level);
+#if P2M_AUDIT
long (*audit_p2m)(struct p2m_domain *p2m);
+#endif
/*
* P2M updates may require TLBs to be flushed (invalidated).
@@ -758,14 +768,6 @@ extern void p2m_pt_init(struct p2m_domai
void *map_domain_gfn(struct p2m_domain *p2m, gfn_t gfn, mfn_t *mfn,
p2m_query_t q, uint32_t *pfec);
-/* Debugging and auditing of the P2M code? */
-#ifndef NDEBUG
-#define P2M_AUDIT 1
-#else
-#define P2M_AUDIT 0
-#endif
-#define P2M_DEBUGGING 0
-
#if P2M_AUDIT
extern void audit_p2m(struct domain *d,
uint64_t *orphans,
next prev parent reply other threads:[~2020-10-28 9:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 9:20 [PATCH 0/5] x86/p2m: hook adjustments Jan Beulich
2020-10-28 9:22 ` [PATCH 1/5] x86/p2m: paging_write_p2m_entry() is a private function Jan Beulich
2020-11-10 10:27 ` Roger Pau Monné
2020-11-10 10:32 ` Jan Beulich
2020-10-28 9:22 ` [PATCH 2/5] x86/p2m: collapse the two ->write_p2m_entry() hooks Jan Beulich
2020-10-29 20:36 ` Tim Deegan
2020-11-10 11:06 ` Roger Pau Monné
2020-11-10 13:51 ` Jan Beulich
2020-11-18 9:44 ` Roger Pau Monné
2020-10-28 9:23 ` Jan Beulich [this message]
2020-11-10 11:30 ` [PATCH 3/5] x86/p2m: suppress audit_p2m hook when possible Roger Pau Monné
2020-11-10 13:21 ` Jan Beulich
2020-11-10 14:01 ` Roger Pau Monné
2020-10-28 9:24 ` [PATCH 4/5] x86/HAP: move nested-P2M flush calculations out of locked region Jan Beulich
2020-11-10 11:38 ` Roger Pau Monné
2020-10-28 9:24 ` [PATCH 5/5] x86/p2m: split write_p2m_entry() hook Jan Beulich
2020-10-29 20:46 ` Tim Deegan
2020-11-10 13:59 ` Roger Pau Monné
2020-11-10 14:50 ` Jan Beulich
2020-11-11 12:17 ` Roger Pau Monné
2020-11-12 12:29 ` Jan Beulich
2020-11-12 13:07 ` Roger Pau Monné
2020-11-12 14:04 ` Jan Beulich
2020-11-12 17:52 ` Tim Deegan
2020-11-13 9:52 ` Jan Beulich
2020-11-18 9:22 ` Roger Pau Monné
2020-11-18 9:31 ` Roger Pau Monné
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=722cf75e-da6a-49c5-472a-898796c9030e@suse.com \
--to=jbeulich@suse.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--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.