[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/HVM: fix setting mem access to default
commit ca0f21841ddc4b2e2f4e4a74e2e39b70bd6b0aff Author: Jan Beulich <JBeulich@xxxxxxxx> AuthorDate: Wed Apr 2 09:09:33 2014 +0100 Commit: Tim Deegan <tim@xxxxxxx> CommitDate: Thu Apr 3 10:48:48 2014 +0100 x86/HVM: fix setting mem access to default commit 3b0bcb89 ("x86/mm/p2m: Move p2m code in HVMOP_[gs]et_mem_access into p2m.c") introduced an off-by-one mistake forcing an input of HVMMEM_access_default to always fail. Since related, also eliminate the inefficient setup of an on-stack array for each function invocation. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Tim Deegan <tim@xxxxxxx> --- xen/arch/x86/mm/p2m.c | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index fcc3ed6..c38f334 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1358,25 +1358,32 @@ long p2m_set_mem_access(struct domain *d, unsigned long pfn, uint32_t nr, mfn_t mfn; long rc = 0; - /* N.B. _not_ static: initializer depends on p2m->default_access */ - p2m_access_t memaccess[] = { - p2m_access_n, - p2m_access_r, - p2m_access_w, - p2m_access_rw, - p2m_access_x, - p2m_access_rx, - p2m_access_wx, - p2m_access_rwx, - p2m_access_rx2rw, - p2m_access_n2rwx, - p2m->default_access, + static const p2m_access_t memaccess[] = { +#define ACCESS(ac) [HVMMEM_access_##ac] = p2m_access_##ac + ACCESS(n), + ACCESS(r), + ACCESS(w), + ACCESS(rw), + ACCESS(x), + ACCESS(rx), + ACCESS(wx), + ACCESS(rwx), + ACCESS(rx2rw), + ACCESS(n2rwx), +#undef ACCESS }; - if ( (unsigned) access >= HVMMEM_access_default ) + switch ( access ) + { + case 0 ... ARRAY_SIZE(memaccess) - 1: + a = memaccess[access]; + break; + case HVMMEM_access_default: + a = p2m->default_access; + break; + default: return -EINVAL; - - a = memaccess[access]; + } /* If request to set default access */ if ( pfn == ~0ul ) -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |