Xen Test Framework
main.c
Go to the documentation of this file.
1 
28 #include <xtf.h>
29 
30 const char test_title[] = "XSA-167 PoC";
31 
32 void test_main(void)
33 {
34  mmuext_op_t op =
35  {
37  .arg1.mfn = (-1ULL << L2_PT_SHIFT),
38  };
39 
40  printk(" Attempting to mark mfn %#lx as a superpage\n", op.arg1.mfn);
41  int rc = hypercall_mmuext_op(&op, 1, NULL, DOMID_SELF);
42 
43  switch ( rc )
44  {
45  case -ENOSYS:
46  case -EOPNOTSUPP:
47  return xtf_skip("PV superpage support not detected\n");
48 
49  case -EINVAL:
50  return xtf_success("Xen correctly rejected the bogus mark attempt\n");
51 
52  case 0:
53  return xtf_failure("Marking bogus superpage succeeded\n");
54 
55  default:
56  return xtf_error("Unexpected error %d\n", rc);
57  }
58 }
59 
60 /*
61  * Local variables:
62  * mode: C
63  * c-file-style: "BSD"
64  * c-basic-offset: 4
65  * tab-width: 4
66  * indent-tabs-mode: nil
67  * End:
68  */
#define L2_PT_SHIFT
Definition: page.h:67
#define EINVAL
Definition: errno.h:33
#define MMUEXT_MARK_SUPER
Definition: xen.h:351
void printk(const char *fmt,...)
Definition: console.c:134
#define ENOSYS
Definition: errno.h:43
union mmuext_op::@51 arg1
#define EOPNOTSUPP
Definition: errno.h:51
#define NULL
Definition: stddef.h:12
void xtf_success(const char *fmt,...)
Report test success.
Definition: report.c:38
void xtf_failure(const char *fmt,...)
Report a test failure.
Definition: report.c:94
void test_main(void)
To be implemented by each test, as its entry point.
Definition: main.c:137
Definition: xen.h:355
void xtf_skip(const char *fmt,...)
Report a test skip.
Definition: report.c:66
const char test_title[]
The title of the test.
Definition: main.c:14
void xtf_error(const char *fmt,...)
Report a test error.
Definition: report.c:80
static long hypercall_mmuext_op(const mmuext_op_t ops[], unsigned int count, unsigned int *done, unsigned int foreigndom)
Definition: hypercall.h:148
unsigned int cmd
Definition: xen.h:356
xen_pfn_t mfn
Definition: xen.h:360
#define DOMID_SELF
Definition: xen.h:70