WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Lock memory pages

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Subject: [Xen-devel] Lock memory pages
From: "Nimgaonkar, Satyajeet" <SatyajeetNimgaonkar@xxxxxxxxxx>
Date: Thu, 18 Nov 2010 16:57:34 +0000
Accept-language: en-US
Cc:
Delivery-date: Thu, 18 Nov 2010 09:01:34 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AQHLh0GyRW7lm353Z0206Xz/sU+g+g==
Thread-topic: Lock memory pages
Hi Gianni,
                 I have created a custom hypercall and I want to lock the 
memory pages for this hypercall. Below is the hypercall function I wrote in 
xc_domain.c in tools/libxc.

int hypercall_test(int handle){
    
    int rc;
    int arg=0;

    /* Hypercall definitions */
         
    DECLARE_HYPERCALL;
    hypercall.op     = __HYPERVISOR_jeet1;
    //rc = do_xen_hypercall(handle, &hypercall);
    hypercall.arg[0] = 0;
    hypercall.arg[1] = (unsigned long)&arg;
    if (lock_pages (&arg, sizeof(arg)) != 0)
        printf ("Could not lock the pages");
    else
        printf ("Pages locked successfully");
        
        rc = do_xen_hypercall(handle, &hypercall);
        printf("%d\n", rc);
                
    unlock_pages(&arg, sizeof(arg));            
    
    return rc;
}

Everything compiles correctly and when I call this function from a testing 
program, a hypercall is made successfully along with locking pages. But I am 
not quite sure how to check if the memory pages have been locked or not. 

Can some one please let me know if this is the correct way to achieve this?

Thanks

Regards,
Satyajeet
________________________________________
From: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx 
[xen-devel-bounces@xxxxxxxxxxxxxxxxxxx] on behalf of Nimgaonkar, Satyajeet 
[SatyajeetNimgaonkar@xxxxxxxxxx]
Sent: Tuesday, November 16, 2010 12:37 PM
To: Gianni Tedesco
Cc: Kaushik Barde; Xen Devel
Subject: RE: [Xen-devel] VCPU Structure

Hi Gianni,
               Thanks for your reply. I would certainly prefer to lock the 
pages instead. I checked the source code and in libxc/xc_domain.c, I see some 
code on locking the pages for a hypercall. I my case too, i need to lock memory 
pages assigned to a hypercall. Is that a right place I am looking at or can you 
please redirect me some code samples about locking memory pages.
               Thanks once again.

Regards,
Satyajeet
________________________________________
From: Gianni Tedesco [gianni.tedesco@xxxxxxxxxx]
Sent: Friday, November 12, 2010 12:00 PM
To: Nimgaonkar, Satyajeet
Cc: Kaushik Barde; Xen Devel
Subject: RE: [Xen-devel] VCPU Structure

On Fri, 2010-11-12 at 17:43 +0000, Nimgaonkar, Satyajeet wrote:
> Hi Kaushik,
>                  Here is what I wish to do.
>                  I have implemented a custom hypercall in xen. Now i
> need to access the memory pages that are being assigned to a
> particular process. I intend to do this from the hypercall handler
> itself. Once I have these memory pages, I will compute the hash
> (Memory Integrity block) of it and store it in the VCPU structure.
> This will help me save the state of the memory for a particular
> process. Later I can check if some modification have been done to the
> process by computing and matching the hash value with the one saved in
> the VCPU.
>                 It would be great if you could give me some insight on
> how to achieve this. Any sample code or examples on this would help a
> lot.
>                 Thanks a lot.

One way would be to use the MMU, you can mark those pages read-only in
the page table and then you will get a pagefault for any write to such a
page. In the fault handler you would mark the page as modified and
unprotect it by setting it read/write again.

That would save a lot of time doing expensive calculations when you
could just use the existing hardware acceleration designed for exactly
this purpose.

See Volume 3, Chapter 4 of the Intel architecture software developers
manual.

Gianni


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>