Skip to content

Tyche td0 merge#1

Open
YuChen-Qian wants to merge 12 commits into
mainfrom
tyche-td0-merge
Open

Tyche td0 merge#1
YuChen-Qian wants to merge 12 commits into
mainfrom
tyche-td0-merge

Conversation

@YuChen-Qian

Copy link
Copy Markdown
Collaborator

No description provided.

YuChen-Qian and others added 12 commits November 30, 2023 15:54
Tyche TD0 does not implement memory acceptance for now. Unaccepted
memory was added in UEFI 2.9. The TD needs to accept the memoory given
by the VMM. The UEFI firmware needs to communicate which memory regions
has been accepted through a bitmap to the kernel, and allocate_e820
allocates the bitmap if unaccepted memory is present. Ideally, we should
implement this part inside tyche as well so that each TD can choose
whether or not it accepts the memory or not, but we can skip it for now.

Tyche TD0 does not implement memory encryption. Instead, we make sure
the tyche regions between different domains are configured correctly.

Tyche TD0 will forces SWIOTLB for all of the DMA regions. The SWIOTLB
is essentially a bounce buffer and marked as shared (and decrypted) in
the current kernel implementation. Ideally, a shared tyche region
between the host kvm and the TD0 will be mapped into this region.

Tyche TD0 does not support transferring pages between private and
shared memory for now.

Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
Compile the tyche driver in-tree, so that we can export the symbol of
some of the tyche driver functions and call them from the kvm tyche
backend.

If we keep the tyche driver out of tree, then it would be impossible to
link these external tyche driver symbols and the linux kernel fails to
compile.

Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
If we keep adding object files to obj-$(CONFIG_TYCHE_DRIVER), the kernel
will try to compile a separate .ko for each of the object file...

This commit fixes this issue by adding the $(TARGET_MODULE)-objs and
keep all of the object files there.

Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
The driver so far relied on the domain_handle_t (a file descriptor) to
reference a domain inside its functions.
We won't have a file descriptor from the kvm-tyche backend, so I changed
the API of the src/domains.c functions to take a direct pointer to the
domain.
so that we can directly include the headers there

Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
Add an extra argument to the tyche_create_domain(), so that we can
differentiate the I/O domain from the normal trust domain. The I/O
domain is solely responsible for managing the IOMMU on tyche.

Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
The coherent DMA buffer allocation will be inside the specified swiotlb
range. A separate memory allocator is added for this purpose so that the
coherent DMA buffer allocation will go through functions like
`swiotlb_alloc` and `swiotlb_free`.

We need to turn off the CONFIG_SWIOTLB_DYNAMIC so that linux does not
allocate buffer at runtime.

Tyche needs to first specify some shared regions and the TD0 will first
enumerate the capa and then allocates the bounce buffer on this range.
Once the bounce buffer is allocated successfully, the TD0 asks tyche
to segment the region and will send the capa of the shared region to
tyche. Tyche then updates the IOPT on the IOMMU. There will be no
updates to the IOMMU when the TD0 kernel is running. The TD0 should
not modify the IOMMU and will boot up with "iommu=off".

Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
Signed-off-by: YuChen Qian <yuchenqian96@gmail.com>
YuChen-Qian pushed a commit that referenced this pull request Feb 11, 2024
…phys

When booting with "intremap=off" and "x2apic_phys" on the kernel command
line, the physical x2APIC driver ends up being used even when x2APIC
mode is disabled ("intremap=off" disables x2APIC mode). This happens
because the first compound condition check in x2apic_phys_probe() is
false due to x2apic_mode == 0 and so the following one returns true
after default_acpi_madt_oem_check() having already selected the physical
x2APIC driver.

This results in the following panic:

   kernel BUG at arch/x86/kernel/apic/io_apic.c:2409!
   invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
   CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.4.0-rc2-ver4.1rc2 #2
   Hardware name: Dell Inc. PowerEdge R6515/07PXPY, BIOS 2.3.6 07/06/2021
   RIP: 0010:setup_IO_APIC+0x9c/0xaf0
   Call Trace:
    <TASK>
    ? native_read_msr
    apic_intr_mode_init
    x86_late_time_init
    start_kernel
    x86_64_start_reservations
    x86_64_start_kernel
    secondary_startup_64_no_verify
    </TASK>

which is:

setup_IO_APIC:
  apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n");
  for_each_ioapic(ioapic)
  	BUG_ON(mp_irqdomain_create(ioapic));

Return 0 to denote that x2APIC has not been enabled when probing the
physical x2APIC driver.

  [ bp: Massage commit message heavily. ]

Fixes: 9ebd680 ("x86, apic: Use probe routines to simplify apic selection")
Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Kishon Vijay Abraham I <kvijayab@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230616212236.1389-1-dheerajkumar.srivastava@amd.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants