On Sun, 18 Aug 2019, Thomas Gleixner wrote:

> On Sun, 18 Aug 2019, Thomas Gleixner wrote:
> > 
> > Patch below. I tested this with the normal order and by installing a
> > 'timens' page unconditionally for all processes. I'll reply with the timens
> > testing hacks so you can see what I did.
> 
> First hack...

And the second one.

Thanks,

        tglx

8<-----------------

Subject: x86/vdso: Hack to test the time namespace path
From: Thomas Gleixner <t...@linutronix.de>
Date: Sun, 18 Aug 2019 16:49:00 +0200

Install a special TIMENS vvar page which forces the VDSO to take the time
namespace path for testing.

Not-Signed-off-by: Thomas Gleixner <t...@linutronix.de>
---
 arch/x86/entry/vdso/vma.c |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -84,6 +84,33 @@ static int vdso_mremap(const struct vm_s
        return 0;
 }
 
+/* Hack for testing */
+static struct page *vdso_timens_page;
+
+static int __init init_vdso_timens(void)
+{
+       struct vdso_data *vdata;
+       void *va;
+
+       vdso_timens_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+       if (!vdso_timens_page)
+               return -ENOMEM;
+
+       /* Hack: vdso data is at offset 0x80 in the page ... */
+       va = page_address(vdso_timens_page);
+       vdata = (struct vdso_data *)(va + 0x80);
+
+       vdata[0].seq = 1;
+       vdata[0].clock_mode = UINT_MAX;
+       vdata[1].seq = 1;
+       vdata[1].clock_mode = UINT_MAX;
+
+       /* All offsets are zero */
+
+       return 0;
+}
+subsys_initcall(init_vdso_timens);
+
 static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
                      struct vm_area_struct *vma, struct vm_fault *vmf)
 {
@@ -106,7 +133,7 @@ static vm_fault_t vvar_fault(const struc
        if (sym_offset == 0)
                return VM_FAULT_SIGBUS;
 
-       if (sym_offset == image->sym_vvar_page) {
+       if (sym_offset == image->sym_timens_page) {
                return vmf_insert_pfn(vma, vmf->address,
                                __pa_symbol(&__vvar_page) >> PAGE_SHIFT);
        } else if (sym_offset == image->sym_pvclock_page) {
@@ -123,6 +150,11 @@ static vm_fault_t vvar_fault(const struc
                if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK))
                        return vmf_insert_pfn(vma, vmf->address,
                                        vmalloc_to_pfn(tsc_pg));
+       } else if (sym_offset == image->sym_vvar_page) {
+               unsigned long pfn;
+
+               pfn = page_to_pfn(vdso_timens_page);
+               return vmf_insert_pfn(vma, vmf->address, pfn);
        }
 
        return VM_FAULT_SIGBUS;

Reply via email to