Re: [PATCH v7 08/16] i386: Expose module level in CPUID[0x1F]

2024-01-15 Thread Yuan Yao
On Mon, Jan 15, 2024 at 03:20:37PM +0800, Zhao Liu wrote: > On Mon, Jan 15, 2024 at 02:57:30PM +0800, Yuan Yao wrote: > > Date: Mon, 15 Jan 2024 14:57:30 +0800 > > From: Yuan Yao > > Subject: Re: [PATCH v7 08/16] i386: Expose module level in CPUID[0x1F] > > > > O

Re: [PATCH v7 08/16] i386: Expose module level in CPUID[0x1F]

2024-01-14 Thread Yuan Yao
On Mon, Jan 15, 2024 at 02:20:20PM +0800, Zhao Liu wrote: > On Mon, Jan 15, 2024 at 01:20:22PM +0800, Yuan Yao wrote: > > Date: Mon, 15 Jan 2024 13:20:22 +0800 > > From: Yuan Yao > > Subject: Re: [PATCH v7 08/16] i386: Expose module level in CPUID[0x1F] > >

Re: [PATCH v7 08/16] i386: Expose module level in CPUID[0x1F]

2024-01-14 Thread Yuan Yao
On Mon, Jan 15, 2024 at 12:34:12PM +0800, Xiaoyao Li wrote: > On 1/15/2024 12:09 PM, Zhao Liu wrote: > > Hi Yuan, > > > > On Mon, Jan 15, 2024 at 11:25:24AM +0800, Yuan Yao wrote: > > > Date: Mon, 15 Jan 2024 11:25:24 +0800 > > > From: Yuan Yao > >

Re: [PATCH v7 08/16] i386: Expose module level in CPUID[0x1F]

2024-01-14 Thread Yuan Yao
On Mon, Jan 08, 2024 at 04:27:19PM +0800, Zhao Liu wrote: > From: Zhao Liu > > Linux kernel (from v6.4, with commit edc0a2b595765 ("x86/topology: Fix > erroneous smp_num_siblings on Intel Hybrid platforms") is able to > handle platforms with Module level enumerated via CPUID.1F. > > Expose the

Re: [RFC PATCH 0/2] Add flag as THP allocation hint for memfd_restricted() syscall

2023-02-19 Thread Yuan Yao
On Sat, Feb 18, 2023 at 12:43:00AM +, Ackerley Tng wrote: > Hello, > > This patchset builds upon the memfd_restricted() system call that has > been discussed in the ‘KVM: mm: fd-based approach for supporting KVM’ > patch series, at >

Re: [PATCH v3 1/6] i386: Introduce FeatureWordInfo for AMX CPUID leaf 0x1D and 0x1E

2023-02-05 Thread Yuan Yao
On Fri, Jan 06, 2023 at 12:38:21AM -0800, Lei Wang wrote: > CPUID leaf 0x1D and 0x1E enumerate tile and TMUL information for AMX. > > Introduce FeatureWord FEAT_1D_1_EAX, FEAT_1D_1_EBX, FEAT_1D_1_ECX and > FEAT_1E_0_EBX. Thus these features of AMX can be expanded when > "-cpu host/max" and can be

Re: [PATCH v3 4/6] i386: Mask and report unavailable multi-bit feature values

2023-02-05 Thread Yuan Yao
On Fri, Jan 06, 2023 at 12:38:24AM -0800, Lei Wang wrote: > Some feature words, e.g., feature words in AMX-related CPUID leaf 0x1D and > 0x1E are not bit-wise but multiple bits represents one value. Handle this > situation when the values specified are not the same as which are reported > by KVM.

Re: [PATCH v10 8/9] KVM: Handle page fault for private memory

2022-12-08 Thread Yuan Yao
On Thu, Dec 08, 2022 at 07:23:46PM +0800, Chao Peng wrote: > On Thu, Dec 08, 2022 at 10:29:18AM +0800, Yuan Yao wrote: > > On Fri, Dec 02, 2022 at 02:13:46PM +0800, Chao Peng wrote: > > > A KVM_MEM_PRIVATE memslot can include both fd-based private memory and > > &

Re: [PATCH v10 6/9] KVM: Unmap existing mappings when change the memory attributes

2022-12-08 Thread Yuan Yao
On Thu, Dec 08, 2022 at 07:20:43PM +0800, Chao Peng wrote: > On Wed, Dec 07, 2022 at 04:13:14PM +0800, Yuan Yao wrote: > > On Fri, Dec 02, 2022 at 02:13:44PM +0800, Chao Peng wrote: > > > Unmap the existing guest mappings when memory attribute is changed > > >

Re: [PATCH v10 8/9] KVM: Handle page fault for private memory

2022-12-07 Thread Yuan Yao
On Fri, Dec 02, 2022 at 02:13:46PM +0800, Chao Peng wrote: > A KVM_MEM_PRIVATE memslot can include both fd-based private memory and > hva-based shared memory. Architecture code (like TDX code) can tell > whether the on-going fault is private or not. This patch adds a > 'is_private' field to

Re: [PATCH v10 6/9] KVM: Unmap existing mappings when change the memory attributes

2022-12-07 Thread Yuan Yao
On Fri, Dec 02, 2022 at 02:13:44PM +0800, Chao Peng wrote: > Unmap the existing guest mappings when memory attribute is changed > between shared and private. This is needed because shared pages and > private pages are from different backends, unmapping existing ones > gives a chance for page fault

Re: [PATCH v9 5/8] KVM: Register/unregister the guest private memory regions

2022-11-08 Thread Yuan Yao
On Tue, Nov 08, 2022 at 05:41:41PM +0800, Chao Peng wrote: > On Tue, Nov 08, 2022 at 09:35:06AM +0800, Yuan Yao wrote: > > On Tue, Oct 25, 2022 at 11:13:41PM +0800, Chao Peng wrote: > > > Introduce generic private memory register/unregister by reusing existing > > > SEV

Re: [PATCH v9 6/8] KVM: Update lpage info when private/shared memory are mixed

2022-11-08 Thread Yuan Yao
On Tue, Oct 25, 2022 at 11:13:42PM +0800, Chao Peng wrote: > When private/shared memory are mixed in a large page, the lpage_info may > not be accurate and should be updated with this mixed info. A large page > has mixed pages can't be really mapped as large page since its > private/shared pages

Re: [PATCH v9 5/8] KVM: Register/unregister the guest private memory regions

2022-11-07 Thread Yuan Yao
On Tue, Oct 25, 2022 at 11:13:41PM +0800, Chao Peng wrote: > Introduce generic private memory register/unregister by reusing existing > SEV ioctls KVM_MEMORY_ENCRYPT_{UN,}REG_REGION. It differs from SEV case > by treating address in the region as gpa instead of hva. Which cases > should these

[PATCH v2 1/1] i386/monitor: Fix page table walking issue for LA57 enabled guest

2022-06-27 Thread Yuan Yao
Fixes tag (Markus Armbruster ). Fixes: 6c7c3c21f9 ("x86: implement la57 paging mode") Signed-off-by: Yuan Yao Reviewed-by: Zhang Chen --- target/i386/monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/monitor.c b/target/i386/monito

[PATCH 1/1] i386/monitor: Fix page table walking issue for LA57 enabled guest

2022-06-09 Thread Yuan Yao
Don't skip next leve page table for pdpe/pde when the PG_PRESENT_MASK is set. This fixs the issue that no mapping information was collected from "info mem" for guest with LA57 enabled. Signed-off-by: Yuan Yao --- target/i386/monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2

Re: [PATCH v4 3/3] i386: Add notify VM exit support

2022-05-24 Thread Yuan Yao
On Tue, May 24, 2022 at 10:03:02PM +0800, Chenyi Qiang wrote: > There are cases that malicious virtual machine can cause CPU stuck (due > to event windows don't open up), e.g., infinite loop in microcode when > nested #AC (CVE-2015-5307). No event window means no event (NMI, SMI and > IRQ) can be

[PATCH 1/1] i386/monitor: Fix inverse PG_PRESENT_MASK checking in mem_info_la57()

2021-10-08 Thread Yuan Yao
The inverse pdpe/pde PG_PRESENT_MASK checking causes no mapping information was collected from "info mem" for guest with LA57 enabled. Fixes: 6c7c3c21f9 ("x86: implement la57 paging mode") Signed-off-by: Yuan Yao --- target/i386/monitor.c | 4 ++-- 1 file changed, 2 insert

[RFC][PATCH v1 10/10] Introduce new CPUClass::get_phys_page_attrs_debug implementation for encrypted guests

2021-05-05 Thread Yuan Yao
From: Yuan Yao Add new function x86_cpu_get_phys_page_attrs_encrypted_debug() to walking guset page tables to do VA -> PA translation for encrypted guests. Now install this to cc->get_phys_page_attrs_debug for INTEL TD guests only. Signed-off-by: Yuan Yao diff --git a/target/i386/c

[RFC][PATCH v1 08/10] Introduce debug version of physical memory read/write API

2021-05-05 Thread Yuan Yao
From: Yuan Yao Add below APIs for reading/writing the physical memory, subsequent patch will use them in monitor commands and gdbstub to support encrypted guest debugging. uint32_t x86_ldl_phys_debug(CPUState *cs, hwaddr addr); uint64_t x86_ldq_phys_debug(CPUState *cs, hwaddr addr); void

[RFC][PATCH v1 05/10] Set the RAM's MemoryRegion::debug_ops for INTEL TD guests

2021-05-05 Thread Yuan Yao
From: Yuan Yao Now only set the RAM's debug_ops for INTEL TD guests, SEV can also rely on the common part introduced in previous patch or introduce new debug_ops implementation if it's necessary. Signed-off-by: Yuan Yao diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d5a4345f44..772b19c524

[RFC][PATCH v1 02/10] Currently, guest memory access for debugging purposes is performed using memcpy(). Extend the 'struct MemoryRegion' to include new callbacks that can be used to override the use

2021-05-05 Thread Yuan Yao
); mem_write(uint8_t *hva_dest, hwaddr gpa_des, const uint8_t *src, uint32_t len, MemTxAttrs attrs); MemoryRegionRAMReadWriteOps ops; ops.read = mem_read; ops.write = mem_write; memory_region_init_ram(mem, NULL, "memory", size, NULL); memory_region_set_ram_debug_ops(mem, ops);

[RFC][PATCH v1 09/10] Change the monitor and other commands and gdbstub to use the debug API

2021-05-05 Thread Yuan Yao
From: Yuan Yao Please comment if some changes are incorrect or I missed something here. Signed-off-by: Yuan Yao diff --git a/dump/dump.c b/dump/dump.c index 929138e91d..21eb018092 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1746,7 +1746,7 @@ static void dump_init(DumpState *s, int fd, bool

[RFC][PATCH v1 04/10] Implements the common MemoryRegion::ram_debug_ops for encrypted guests

2021-05-05 Thread Yuan Yao
From: Yuan Yao The new functions are added into target/i386/kvm/kvm.c as common functions to support encrypted guest for KVM on x86. Now we enable these only for INTEL TD guests. Signed-off-by: Yuan Yao diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 05bf4f8b8b..5050b2a82f

[RFC][PATCH v1 01/10] Extend the MemTxAttrs to include a 'debug' flag. The flag can be used as general indicator that operation was triggered by the debugger.

2021-05-05 Thread Yuan Yao
From: Brijesh Singh A subsequent patch will set the debug=1 when issuing a memory access from the gdbstub or HMP commands. This is a prerequisite to support debugging an encrypted guest. When a request with debug=1 is seen, the encryption APIs will be used to access the guest memory.

[RFC][PATCH v1 07/10] Add new address_space_read and address_space_write debug helper interfaces which can be invoked by vendor specific guest memory debug assist/hooks to do guest RAM memory accesses

2021-05-05 Thread Yuan Yao
From: Ashish Kalra Yuan Yao: - Fixed fuzz_dma_read_cb() parameter issue for QEMU 5.2.91. - Move the caller of encrypted_memory_debug_ops into phymem.c as common callbacks for encrypted guests. - Adapted address_space_read_debug/address_space_wirte_rom_debug with new

[RFC][PATCH v1 06/10] Introduce new MemoryDebugOps which hook into guest virtual and physical memory debug interfaces such as cpu_memory_rw_debug, to allow vendor specific assist/hooks for debugging a

2021-05-05 Thread Yuan Yao
From: Ashish Kalra The MemoryDebugOps are used by cpu_memory_rw_debug() and default to address_space_read and address_space_write_rom. Yuan Yao: Exports the physical_memory_debug_ops variable for functions in target/i386/helper.c Signed-off-by: Ashish Kalra Signed-off-by: Yuan Yao diff

[RFC][PATCH v1 03/10] Introduce new interface KVMState::set_mr_debug_ops and its wrapper

2021-05-05 Thread Yuan Yao
From: Yuan Yao This interface is designed to setup the MemoryRegion::debug_ops. Also introduced 2 wrapper functions for installing/calling the KVMState::set_mr_debug_ops from different targets easily. Signed-off-by: Yuan Yao diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index

[RFC][PATCH v1 00/10] Enable encrypted guest memory access in QEMU

2021-05-05 Thread Yuan Yao
From: Yuan Yao This RFC series introduces the basic framework and a common implementation on x86 to handle encrypted guest memory reading/writing, to support QEMU's built-in guest debugging features, like the monitor command xp and gdbstub. The encrypted guest which its memory and/or register