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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Johnson, Ethan" <ejohns48@xxxxxxxxxxxxxxxx>
  • Date: Wed, 15 Mar 2023 02:01:29 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cs.rochester.edu; dmarc=pass action=none header.from=cs.rochester.edu; dkim=pass header.d=cs.rochester.edu; 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=7bS4bqKdaHpKCLCbXaeXVWQzqV3Jo/P6WhYxvLdZVUA=; b=HkBSQTVQJYtlm1C88rB26MKP6dmoIwTYgSgthcsCOkORZqqw7+FqoOSovIpP1qxjqHRySaTBx9AQupmaeCMFQEz/Y/H7IXo5CBBHG3WqAt+VloFQESzvfSBn90uAFXydj4nDZlClg08xGraWrcz6q8lmYhbTGrACLEJGWVtnFH5G3abME0fSnBiRudOVrqSGPb3gUEGitKA7JhjWNinlRlVUfdqzjz2KuhqiaDD6FOasBxO/IHEl2xgXti1Ki3woH4Sm5pvGNtRQQkEE3D/5ct0D+hPnjW1TAojkzD4z+SitWKdF2whHyAXqNN1kFHmpLX8UYA47zyjoy9szIC3RDg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H83Rndx2svK0WRZCYlY4gSaWSzFcn1BHhMrTGEBncE+o9JPjivpwC4ReOlIuoHshkHnDB8hKJuy/OcNWggmE7tIk59DYb1qbK9RWiVEytV30lRe9VBzZ5EVVBeMTg2JX8XGA6D4gq+qIleBEGDBTBsvCCSVlEB8bBFMMYPaEk/F1inu49XsVm3Hib5MRhG0Q1QF2OgsB929Tj8+zPAXGTTq5juV/CRtVAblZislmc3LU7/StLR4pmGiwHPQHXBd4NAmFbUfIG3xbkG1KVWR7yRXsqdx8X5lNE5VqRbocemVsqspDviN8K2YQEbxxcAct+tDgJX0+yqmlOH7KOo8tsw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cs.rochester.edu;
  • Delivery-date: Wed, 15 Mar 2023 02:02:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AdlW4ZyKUvgJbymyR8ifY2W3pwWzBw==
  • Thread-topic: Best way to use altp2m to support VMFUNC EPT-switching?

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!

Sincerely,

Ethan Johnson
Computer Science PhD candidate, Systems group, University of Rochester
mailto:ejohns48@xxxxxxxxxxxxxxxx



 


Rackspace

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