x86/mce: handle reserved domain ID in XEN_MC_msrinject

Commit 26646f3 "x86/mce: translate passed-in GPA to host machine
address" and commit 4ddf474 "tools/xen-mceinj: Pass in GPA when
injecting through MSR_MCI_ADDR" forgot to consider reserved domain
ID and mistakenly add MC_MSRINJ_F_GPADDR flag for them, which in turn
causes bug reported by
http://lists.xenproject.org/archives/html/xen-devel/2016-05/msg02640.html.

This patch removes MC_MSRINK_F_GPADDR flag and checks this when injecting
to reserved domain IDs except DOMID_SELF, and treats the passed-in
address as host machine address.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Christoph Egger <chegger@amazon.de>
This commit is contained in:
Haozhong Zhang authored and Jan Beulich committed 2016-06-08 11:08:55 +02:00
1 parent 936a7a5483
commit e63888627a
2 files changed
+15 -4

No files matched your search

+4 -1
View File
@@ -317,7 +317,10 @@ static int inject_mci_addr(xc_interface *xc_handle,
domid_t domid)
{
return add_msr_bank_intpose(xc_handle, cpu_nr,
MC_MSRINJ_F_INTERPOSE | MC_MSRINJ_F_GPADDR,
MC_MSRINJ_F_INTERPOSE |
((domid >= DOMID_FIRST_RESERVED &&
domid != DOMID_SELF) ?
0 : MC_MSRINJ_F_GPADDR),
MCi_type_ADDR, bank, val, domid);
}
+11 -3
View File
@@ -1427,6 +1427,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)
if ( mc_msrinject->mcinj_flags & MC_MSRINJ_F_GPADDR )
{
domid_t domid;
struct domain *d;
struct mcinfo_msr *msr;
unsigned int i;
@@ -1434,10 +1435,17 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)
unsigned long gfn, mfn;
p2m_type_t t;
d = get_domain_by_id(mc_msrinject->mcinj_domid);
domid = (mc_msrinject->mcinj_domid == DOMID_SELF) ?
current->domain->domain_id : mc_msrinject->mcinj_domid;
if ( domid >= DOMID_FIRST_RESERVED )
return x86_mcerr("do_mca inject: incompatible flag "
"MC_MSRINJ_F_GPADDR with domain %d",
-EINVAL, domid);
d = get_domain_by_id(domid);
if ( d == NULL )
return x86_mcerr("do_mca inject: bad domain id %d",
-EINVAL, mc_msrinject->mcinj_domid);
-EINVAL, domid);
for ( i = 0, msr = &mc_msrinject->mcinj_msr[0];
i < mc_msrinject->mcinj_count;
@@ -1452,7 +1460,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)
put_gfn(d, gfn);
put_domain(d);
return x86_mcerr("do_mca inject: bad gfn %#lx of domain %d",
-EINVAL, gfn, mc_msrinject->mcinj_domid);
-EINVAL, gfn, domid);
}
msr->value = pfn_to_paddr(mfn) | (gaddr & (PAGE_SIZE - 1));
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.