[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to use altp2m to support VMFUNC EPT-switching?


  • To: "Johnson, Ethan" <ejohns48@xxxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 15 Mar 2023 09:22:17 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JAZCYEk/6QhRdJkgXCJO7QvbaxYyIjijeR24io91KZQ=; b=FyMTaVomJGybj1E9pr2wS/BGZjRTg8syIgGWnEHc6stXSed0BrhuiRKQSXR8CqIjl8A1qlzOorcDxVfVAgo0cT6JAAZ7m73FYUD55l76omh0ntiu6IvIbSLAPX1hBtdmTovqtdb8rs/KVyNH/nktKfGkuMQciJSGGGrXMhzzPxw1+71GPIzlbno2Wtj+rGRrD/bh/ct8L8lC7wTzorWteLkrMLS2WGogdOU+MHz7ubwTwXpW/zEv7IyAR6CHoKKqh94ZX9USVLlAY/VzMYIL08NKTT+1dm5hZCaU2y4L7ZmFw4IlA+VQnYck8hfLKRAlgfHJvbQEOTKPm7d5U4WEZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZJkUGCXgSqgB/1eaGGQeEMTUC9/n30AoFCeZi4aHzxHr2BbiBfL1T1cUJ7tGEn1ATlAc/2Rrq5con0fgepTZr0YgS5KXCzS3RUeE68Bk9sJKeQlZt5SrCc4764vTnevr+HTME6wn4/xHfP/Pj1HfynNeUIGvCZp5MK3EMbwgFQHQKE1cfIy8/aNVBk/bFpNtMcdX1BPWt1+oC6OqvtSfXyR6O3pqt/fmsW4qkqX9asxFDKDaoND9gxTiPV/OR/0BjHWupw+w2g7fxPoYrMxHiVbB2bB1kPNsYih+ccLZkWrBxeY/PwBChxwVgl9VGXdjaU4T51H72qdZTKkHLVTtXw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Wed, 15 Mar 2023 09:22:36 +0000
  • Ironport-data: A9a23:t36Y/K6/AN/KxHIDzFkxAwxRtB7GchMFZxGqfqrLsTDasY5as4F+v mBMXm+OOvmIZzf3etwlbdm290IPsZOEmodjSQFu/Hw0Hi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+7JwehBtC5gZlPasS4QeH/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5mz v0FeTxSdiG6neu9x5ygVsNl29skBZy+VG8fkikIITDxK98DGcqGeIOToNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6Ok0otjdABM/KMEjCObexTklyVu STt+GPhDwtBHNee1SCE4jSngeqncSbTAdpLT+fpq6E16LGV7kNMAh8Za2u1nf/6sEunBcphI k4ZpAN7+MDe82TuFLERRSaQrXyDvhgHB4p4GPZ88gaGyqfP/wuDQGUIU1ZpeNEg8cM7WzEu/ luIhM/yQyxitqWPTnCQ/avSqim9URX5NkcHbC4ACBADut/qpdlpigqVFoo+VqmoktfyBDf8h SiQqzQzjKkSishN0Lin+VfAgHSnoZ2hohMJ2zg7l1mNtmtRDLNJraTygbQHxZ6s9Lqkc2Q=
  • Ironport-hdrordr: A9a23:Da47O63EAO0SClum4W51bwqjBAkkLtp133Aq2lEZdPWaSK2lfq eV7ZImPH7P+VEssRQb8+xoV5PsfZqxz/JICMwqTNSftOePghrVEGgg1/qe/9XYcxeOidK1rJ 0QDZSWaueRMbEKt7ef3ODiKadY/DDvysnB7ts2jU0dLz2CDZsO0+4TMHf/LqQZfmd77LMCZe uhz/sCiTq8WGgdKv+2DmMCWIH41qf2vaOjTx4aJgItrDKDhzOw6LL8DnGjr2wjegIK77c+0H TP1zf07KW7s/2911v12mLJ445N8eGRuudrNYijitU1Nj6psAquaYh7MofyxAwInA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15/03/2023 2:01 am, Johnson, Ethan wrote:
> Hi all,
>
> I'm looking for some pointers on how Xen's altp2m system works and how it's 
> meant to be used with Intel's VMFUNC EPT-switching for secure isolation 
> within an HVM/PVH guest's kernelspace.
>
> Specifically, I am attempting to modify Xen to create (on request by an 
> already-booted, cooperative guest with a duly modified Linux kernel) a second 
> set of extended page tables that have access to additional privileged regions 
> of host-physical memory (specifically, a page or two to store some sensitive 
> data that we don't want the guest kernel to be able to overwrite, plus some 
> host-physical MMIO ranges, specifically the xAPIC region). The idea is that 
> the guest kernel will use VMFUNC to switch to the alternate EPTs and call 
> "secure functions" provided (by the hypervisor) as read-only code to be 
> executed in non-root mode on the alternate EPT, allowing certain VM-exit 
> scenarios (namely, sending an IPI to another vCPU of the same domain) to be 
> handled without exiting non-root mode. Hence, these extra privileged pages 
> should only be visible to the alternative p2m that the "secure realm" 
> functions live in. (Transitions between the secure- and insecure-realm EPTs 
> will be through special read-only "trampoline" code pages that ensure the 
> untrusted guest kernel can only enter the secure realm at designated entry 
> points.)
>
> Looking at Xen's existing altp2m code, I get the sense that Xen is already 
> designed to support something at least vaguely like this. I have not, 
> however, been able to find much in the way of documentation on altp2m, so I 
> am reaching out to see if anyone can offer pointers on how to best use it.
>
> What is the intended workflow (either in the toolstack or within the 
> hypervisor itself) for creating and configuring an altp2m that should have 
> access to additional host-physical frames that are not present in the guest's 
> main p2m?
>
> FWIW, once the altp2m has been set up in this fashion, we don't anticipate 
> needing to fiddle with its mappings any further as long as the guest is 
> running (so I'm thinking *maybe* the "external" altp2m mode will suffice for 
> this). In fact, we may not even need to have any "overlap" between the 
> primary and alternative p2m except the trampoline pages themselves (although 
> this aspect of our design is still somewhat in flux).
>
> I've noticed a function, do_altp2m_op(), in the hypervisor 
> (xen/arch/x86/hvm/hvm.c) that seems to implement a number of altp2m-related 
> hypercalls intended to be called from the dom0. Do these hypercalls already 
> provide a straightforward way to achieve my goals described above entirely 
> via (a potentially modified version of) the dom0 toolstack? Or would I be 
> better off creating and configuring the altp2m from within the hypervisor 
> itself, since I want to map low-level stuff like xAPIC MMIO ranges into the 
> altp2m?
>
> Thank you in advance for your time and assistance!

Hello,

There's a lot to unpack here, but before I do so, one question.  In your
usecase, are you wanting to map any frames with reduced permissions
(i.e. such that you'd get a #VE exception), or are you just looking to
add new frames with RWX perms into an alternative view?

I suspect the latter, but it's not completely clear, and changes the answer.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.