[RFC 1/2] system/memory: Allow creating IOMMU mappings from RAM discard populate notifiers

2025-02-20 Thread Jean-Philippe Brucker
() notifier. We can't easily invert the order of operation because it uses the old state bitmap to know which pages need the populate() notifier. For now add a flag to the IOMMU notifier to tell memory_get_xlat_addr() that we're aware of the RAM discard manager state. Signed-off-

[RFC 0/2] arm: Add DMA remapping for CCA

2025-02-20 Thread Jean-Philippe Brucker
sting VFIO support using Chenyi Qiang's series for shared device assignment [2] [1] https://lore.kernel.org/qemu-devel/20241125195626.856992-2-jean-phili...@linaro.org/ [2] https://lore.kernel.org/qemu-devel/20250217081833.21568-1-chenyi.qi...@intel.com/ Jean-Philippe Brucker (2): system/m

[RFC 2/2] target/arm/kvm-rme: Add DMA remapping for the shared memory region

2025-02-20 Thread Jean-Philippe Brucker
ot install its own address space at the moment. And since sysbus devices can't have an IOMMU at the moment, DMA from non-PCI devices isn't supported. Signed-off-by: Jean-Philippe Brucker --- target/arm/kvm_arm.h | 15 +++ hw/arm/virt.c| 2 + target

Re: [PATCH v3 18/26] hw/arm/boot: Mark all guest memory as RIPAS_RAM.

2025-02-07 Thread Jean-Philippe Brucker
On Tue, Feb 04, 2025 at 05:27:17PM +1000, Gavin Shan wrote: > On 11/26/24 5:56 AM, Jean-Philippe Brucker wrote: > > All Realm IPA states are by default RIPAS_EMPTY, and accessing them in > > that state causes injection of synchronous exception. Either the loader > > or the g

Re: [PATCH v3 09/26] target/arm/kvm-rme: Initialize Realm memory

2025-02-07 Thread Jean-Philippe Brucker
On Tue, Feb 04, 2025 at 03:30:00PM +1000, Gavin Shan wrote: > > +hwaddr ram_base; > > +size_t ram_size; > > }; > > s/size_t/hwaddr. To be consistent with RmeRamRegion, we may reuse > it like below. > > struct RmeGuest { > : > GSlist *populate_ram_regions; > RmeRamRegion init

Re: [PATCH v3 08/26] hw/core/loader: Add ROM loader notifier

2025-02-07 Thread Jean-Philippe Brucker
On Tue, Feb 04, 2025 at 03:33:10PM +1000, Gavin Shan wrote: > > diff --git a/include/hw/loader.h b/include/hw/loader.h > > index 7f6d06b956..0cd9905f97 100644 > > --- a/include/hw/loader.h > > +++ b/include/hw/loader.h > > @@ -353,6 +353,21 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, >

Re: [PATCH v3 06/26] target/arm/kvm-rme: Initialize vCPU

2025-02-07 Thread Jean-Philippe Brucker
On Tue, Feb 04, 2025 at 03:02:41PM +1000, Gavin Shan wrote: > > +reg.id = AARCH64_CORE_REG(regs.pc); > > +reg.addr = (uintptr_t) &env->pc; > > +ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); > > +if (ret) { > > +return ret; > > +} > > + > > +return 0; > > +} > > + >

Re: [PATCH v3 17/26] hw/arm/virt: Reserve one bit of guest-physical address for RME

2025-01-22 Thread Jean-Philippe Brucker
Hi Gavin, On Fri, Dec 13, 2024 at 10:03:08PM +1000, Gavin Shan wrote: > Hi Jean, > > On 11/26/24 5:56 AM, Jean-Philippe Brucker wrote: > > When RME is enabled, the upper GPA bit is used to distinguish protected > > from unprotected addresses. Reserve it when setting up the

Re: [RFC PATCH v3 23/26] hw/tpm: Add TPM event log

2024-12-13 Thread Jean-Philippe Brucker
On Mon, Dec 09, 2024 at 05:34:13PM -0500, Stefan Berger wrote: > > > On 11/25/24 2:56 PM, Jean-Philippe Brucker wrote: > > Provide a library allowing the VMM to create an event log that describes > > what is loaded into memory. During remote attestation in confidential >

Re: [RFC PATCH v3 25/26] target/arm/kvm-rme: Add measurement log

2024-12-13 Thread Jean-Philippe Brucker
On Mon, Dec 09, 2024 at 05:08:37PM -0500, Stefan Berger wrote: > > typedef struct { > > hwaddr base; > > hwaddr size; > > +uint8_t *data; > > +RmeLogFiletype *filetype; > > } RmeRamRegion; > > +typedef struct { > > +charsignature[16]; > > +charname[32

Re: [PATCH v3 08/26] hw/core/loader: Add ROM loader notifier

2024-12-10 Thread Jean-Philippe Brucker
On Thu, Dec 05, 2024 at 10:59:52PM +0100, Philippe Mathieu-Daudé wrote: > On 25/11/24 20:56, Jean-Philippe Brucker wrote: > > Add a function to register a notifier, that is invoked after a ROM gets > > loaded into guest memory. > > > > It will be used by Arm confident

Re: [PATCH v3 03/26] target/arm/kvm: Return immediately on error in kvm_arch_init()

2024-12-10 Thread Jean-Philippe Brucker
On Thu, Dec 05, 2024 at 10:47:13PM +0100, Philippe Mathieu-Daudé wrote: > Hi Jean-Philippe, > > On 25/11/24 20:56, Jean-Philippe Brucker wrote: > > Returning an error to kvm_init() is fatal anyway, no need to continue > > the initialization. > > > > Sig

Re: [RFC PATCH v3 26/26] hw/arm/virt: Add measurement log for confidential boot

2024-12-10 Thread Jean-Philippe Brucker
On Thu, Dec 05, 2024 at 11:23:09PM +0100, Philippe Mathieu-Daudé wrote: > On 25/11/24 20:56, Jean-Philippe Brucker wrote: > > Create a measurement log describing operations performed by QEMU to > > initialize the guest, and load it into guest memory above the DTB. > >

Re: [RFC PATCH v3 24/26] hw/core/loader: Add fields to RomLoaderNotify

2024-12-10 Thread Jean-Philippe Brucker
On Thu, Dec 05, 2024 at 11:21:19PM +0100, Philippe Mathieu-Daudé wrote: > On 25/11/24 20:56, Jean-Philippe Brucker wrote: > > In order to write an event log, the ROM load notification handler needs > > two more fields. > > IMHO it makes more sense to squash that in the "

Re: [RFC PATCH v3 25/26] target/arm/kvm-rme: Add measurement log

2024-12-05 Thread Jean-Philippe Brucker
On Mon, Dec 02, 2024 at 10:58:01AM -0500, Stefan Berger wrote: > > > On 11/26/24 11:21 AM, Jean-Philippe Brucker wrote: > > On Tue, Nov 26, 2024 at 01:45:55PM +, Daniel P. Berrangé wrote: > > > On Mon, Nov 25, 2024 at 05:23:44PM -0500, Stefan Berger wrote: > >

Re: [PATCH v3 10/26] target/arm/kvm-rme: Add Realm Personalization Value parameter

2024-12-04 Thread Jean-Philippe Brucker
On Tue, Nov 26, 2024 at 12:47:59PM +, Daniel P. Berrangé wrote: > On Tue, Nov 26, 2024 at 08:20:42AM +0100, Markus Armbruster wrote: > > Jean-Philippe Brucker writes: > > > > > The Realm Personalization Value (RPV) is provided by the user to > > > dist

Re: [PATCH v3 10/26] target/arm/kvm-rme: Add Realm Personalization Value parameter

2024-12-04 Thread Jean-Philippe Brucker
On Tue, Nov 26, 2024 at 08:20:42AM +0100, Markus Armbruster wrote: > > +# @personalization-value: Realm personalization value, as a 64-byte > > +# hex string. This optional parameter allows to uniquely identify > > +# the VM instance during attestation. (default: 0) > > QMP commonly uses b

Re: [PATCH v3 02/26] target/arm: Add confidential guest support

2024-12-04 Thread Jean-Philippe Brucker
On Tue, Nov 26, 2024 at 12:37:02PM +, Daniel P. Berrangé wrote: > When you create a new "user creatable" object, there should also be a > corresponding addition to qapi/qom.json. > > I believe you have the qom.json addition in a later patch, but it > should actually be here Yes, I'll move it

Re: [PATCH v3 01/26] kvm: Merge kvm_check_extension() and kvm_vm_check_extension()

2024-12-04 Thread Jean-Philippe Brucker
On Tue, Nov 26, 2024 at 12:29:35PM +, Daniel P. Berrangé wrote: > On Mon, Nov 25, 2024 at 07:56:00PM +0000, Jean-Philippe Brucker wrote: > > The KVM_CHECK_EXTENSION ioctl can be issued either on the global fd > > (/dev/kvm), or on the VM fd obtained with KVM_CREATE_VM. For most

Re: [PATCH v3] tests/functional/aarch64: add tests for FEAT_RME

2024-12-03 Thread Jean-Philippe Brucker
On Mon, Dec 02, 2024 at 04:17:41PM -0800, Pierrick Bouvier wrote: > This boot an OP-TEE environment, and launch a nested guest VM inside it > using the Realms feature. We do it for virt and sbsa-ref platforms. > > Signed-off-by: Pierrick Bouvier > > - > > v2: > - move test to its own file >

Re: [RFC PATCH v3 25/26] target/arm/kvm-rme: Add measurement log

2024-11-26 Thread Jean-Philippe Brucker
On Tue, Nov 26, 2024 at 01:45:55PM +, Daniel P. Berrangé wrote: > On Mon, Nov 25, 2024 at 05:23:44PM -0500, Stefan Berger wrote: > > > > > > On 11/25/24 2:56 PM, Jean-Philippe Brucker wrote: > > > Create an event log, in the format defined by Trusted Comp

[PATCH v3 11/26] target/arm/kvm-rme: Add measurement algorithm property

2024-11-25 Thread Jean-Philippe Brucker
pport acceleration via FEAT_SHA256 (Armv8.0) and not FEAT_SHA512 (Armv8.2). Future CPUs supporting RME are likely to also support FEAT_SHA512. Cc: Eric Blake Cc: Markus Armbruster Cc: Daniel P. Berrangé Cc: Eduardo Habkost Acked-by: Markus Armbruster Signed-off-by: Jean-Philippe Brucker --- v

[PATCH v3 09/26] target/arm/kvm-rme: Initialize Realm memory

2024-11-25 Thread Jean-Philippe Brucker
Initialize the IPA state of RAM. Collect the images copied into guest RAM into a sorted list, and issue POPULATE_REALM KVM ioctls once we've created the Realm Descriptor. The images are part of the Realm Initial Measurement. Signed-off-by: Jean-Philippe Brucker --- v2->v3: RIPA

[PATCH v3 15/26] hw/arm/virt: Add support for Arm RME

2024-11-25 Thread Jean-Philippe Brucker
When confidential-guest-support is enabled for the virt machine, add the RME flag to the VM type. The HVC conduit for PSCI is not supported for Realms. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw

[PATCH v3 03/26] target/arm/kvm: Return immediately on error in kvm_arch_init()

2024-11-25 Thread Jean-Philippe Brucker
Returning an error to kvm_init() is fatal anyway, no need to continue the initialization. Signed-off-by: Jean-Philippe Brucker --- target/arm/kvm.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 8bdf4abeb6..95bcecf804

[PATCH v3 10/26] target/arm/kvm-rme: Add Realm Personalization Value parameter

2024-11-25 Thread Jean-Philippe Brucker
. Berrangé Cc: Eduardo Habkost Acked-by: Markus Armbruster Signed-off-by: Jean-Philippe Brucker --- v2->v3: Fix documentation --- qapi/qom.json| 15 ++ target/arm/kvm-rme.c | 111 +++ 2 files changed, 126 insertions(+) diff --git a/q

[PATCH v3 18/26] hw/arm/boot: Mark all guest memory as RIPAS_RAM.

2024-11-25 Thread Jean-Philippe Brucker
] https://docs.kernel.org/arch/arm64/booting.html https://lore.kernel.org/all/20241004144307.66199-12-steven.pr...@arm.com/ Signed-off-by: Jean-Philippe Brucker --- v2->v3: New: the Linux guest does not initialize RIPAS itself anymore, and expects the loader to do it. --- hw/arm/boot.c | 4

[PATCH v3 08/26] hw/core/loader: Add ROM loader notifier

2024-11-25 Thread Jean-Philippe Brucker
. Signed-off-by: Jean-Philippe Brucker --- include/hw/loader.h | 15 +++ hw/core/loader.c| 15 +++ 2 files changed, 30 insertions(+) diff --git a/include/hw/loader.h b/include/hw/loader.h index 7f6d06b956..0cd9905f97 100644 --- a/include/hw/loader.h +++ b/include/hw

[PATCH v3 00/26] arm: Run Arm CCA VMs with KVM

2024-11-25 Thread Jean-Philippe Brucker
vsm/blob/main/Documentation/docs/installation/INSTALL.md [10] keybroker-demo with event log support https://github.com/jpbrucker/keybroker-demo/commits/event-log/ Cc: Alex Bennée Cc: Matias Ezequiel Vara Larsen Cc: Paolo Bonzini Cc: Peter Gonda Cc: Peter Maydell Cc: Philippe Mathieu-Daudé

[PATCH v3 19/26] hw/arm/virt: Move virt_flash_create() to machvirt_init()

2024-11-25 Thread Jean-Philippe Brucker
ine->cgs member. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index eb94997914..c4cf69ea33 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2124,6 +2124,8 @@ static void ma

[PATCH v3 20/26] hw/arm/virt: Use RAM instead of flash for confidential guest firmware

2024-11-25 Thread Jean-Philippe Brucker
e any information to the host, hence will not store its variables in clear persistent memory. We can therefore replace the flash device with RAM, and load the firmware there. Signed-off-by: Jean-Philippe Brucker --- include/hw/arm/boot.h | 9 + hw/arm/boot.c

[RFC PATCH v3 25/26] target/arm/kvm-rme: Add measurement log

2024-11-25 Thread Jean-Philippe Brucker
verifier independently compute the Realm Initial Measurement, and check that the data we load into guest RAM is known-good images. Without this log, the verifier has to guess where everything is loaded and in what order. Cc: Stefan Berger Signed-off-by: Jean-Philippe Brucker --- v2->v3: New --- q

[RFC PATCH v3 24/26] hw/core/loader: Add fields to RomLoaderNotify

2024-11-25 Thread Jean-Philippe Brucker
In order to write an event log, the ROM load notification handler needs two more fields. Signed-off-by: Jean-Philippe Brucker --- v2->v3: New --- include/hw/loader.h | 2 ++ hw/core/loader.c| 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/hw/loader.h b/include/hw/loade

[PATCH v3 16/26] hw/arm/virt: Disable DTB randomness for confidential VMs

2024-11-25 Thread Jean-Philippe Brucker
Currently the feature is automatically enabled, unless the user disables it on the command-line. Change it to OnOffAuto, and automatically disable it for confidential VMs, unless the user explicitly enables it. Signed-off-by: Jean-Philippe Brucker --- docs/system/arm/virt.rst | 9 +

[PATCH v3 14/26] target/arm/cpu: Inform about reading confidential CPU registers

2024-11-25 Thread Jean-Philippe Brucker
The host cannot access registers of a Realm. Instead of showing all registers as zero in "info registers", display a message about this restriction. Signed-off-by: Jean-Philippe Brucker --- target/arm/cpu.c | 5 + 1 file changed, 5 insertions(+) diff --git a/target/arm/cpu.c b/

[RFC PATCH v3 26/26] hw/arm/virt: Add measurement log for confidential boot

2024-11-25 Thread Jean-Philippe Brucker
Create a measurement log describing operations performed by QEMU to initialize the guest, and load it into guest memory above the DTB. Cc: Stefan Berger Signed-off-by: Jean-Philippe Brucker --- v2->v3: New --- include/hw/arm/boot.h | 3 +++ include/hw/arm/virt.h | 1 + hw/arm/boo

[RFC PATCH v3 21/26] hw/arm/boot: Load DTB as is for confidential VMs

2024-11-25 Thread Jean-Philippe Brucker
For confidential VMs it may be necessary to measure the DTB, to ensure a malicious host does not insert harmful information in there. In case an external tool can generated and measured the DTB, load it as is without patching it. Signed-off-by: Jean-Philippe Brucker --- v2->v3: new --- hw/

[RFC PATCH v3 22/26] hw/arm/boot: Skip bootloader for confidential guests

2024-11-25 Thread Jean-Philippe Brucker
protocol [1]. [1] https://docs.kernel.org/arch/arm64/booting.html Signed-off-by: Jean-Philippe Brucker --- v2->v3: new --- include/hw/arm/boot.h | 6 ++ hw/arm/boot.c | 23 +-- hw/arm/virt.c | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) d

[PATCH v3 01/26] kvm: Merge kvm_check_extension() and kvm_vm_check_extension()

2024-11-25 Thread Jean-Philippe Brucker
kernel.org/kvm/875ybi0ytc@redhat.com/ [3] https://github.com/torvalds/linux/commit/92b591a4c46b Cc: Marcelo Tosatti Cc: Nicholas Piggin Cc: Daniel Henrique Barboza Cc: qemu-...@nongnu.org Suggested-by: Cornelia Huck Signed-off-by: Jean-Philippe Brucker --- include/sysemu/kvm.h | 2 -

[PATCH v3 12/26] target/arm/cpu: Set number of breakpoints and watchpoints in KVM

2024-11-25 Thread Jean-Philippe Brucker
and watchpoints, and influence the Realm Initial Measurement. Signed-off-by: Jean-Philippe Brucker --- target/arm/cpu.h | 4 ++ target/arm/kvm_arm.h | 2 + target/arm/arm-qmp-cmds.c | 1 + target/arm/cpu64.c| 77 +++ target/arm

[PATCH v3 06/26] target/arm/kvm-rme: Initialize vCPU

2024-11-25 Thread Jean-Philippe Brucker
KVM_GET_REG_LIST. Signed-off-by: Jean-Philippe Brucker --- target/arm/cpu.h | 3 +++ target/arm/kvm_arm.h | 15 +++ target/arm/kvm-rme.c | 10 target/arm/kvm.c | 61 4 files changed, 89 insertions(+) diff --git a/target/arm/cpu.h b

[RFC PATCH v3 23/26] hw/tpm: Add TPM event log

2024-11-25 Thread Jean-Philippe Brucker
t can also copy its content into a new one. [1] https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/ Cc: Stefan Berger Signed-off-by: Jean-Philippe Brucker --- v2->v3: New --- qapi/tpm.json| 14 ++ include/hw/tpm/tpm_log.h | 89 ++

[PATCH v3 17/26] hw/arm/virt: Reserve one bit of guest-physical address for RME

2024-11-25 Thread Jean-Philippe Brucker
When RME is enabled, the upper GPA bit is used to distinguish protected from unprotected addresses. Reserve it when setting up the guest memory map. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/arm

[PATCH v3 04/26] target/arm/kvm-rme: Initialize realm

2024-11-25 Thread Jean-Philippe Brucker
registers are reset, * activate the realm, at which point the realm is sealed. Signed-off-by: Jean-Philippe Brucker --- v2->v3: * Cleaner error handling --- target/arm/kvm_arm.h | 39 target/arm/kvm-rme.c | 106 +++ target/arm/kv

[PATCH v3 13/26] target/arm/cpu: Set number of PMU counters in KVM

2024-11-25 Thread Jean-Philippe Brucker
Add a "num-pmu-counters" CPU parameter to configure the number of counters that KVM presents to the guest. This is needed for Realm VMs, whose parameters include the number of PMU counters and influence the Realm Initial Measurement. Signed-off-by: Jean-Philippe Brucker --- target

[PATCH v3 05/26] target/arm/kvm: Split kvm_arch_get/put_registers

2024-11-25 Thread Jean-Philippe Brucker
The confidential guest support in KVM limits the number of registers that we can read and write. Split the get/put_registers function to prepare for it. Signed-off-by: Jean-Philippe Brucker --- target/arm/kvm.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions

[PATCH v3 02/26] target/arm: Add confidential guest support

2024-11-25 Thread Jean-Philippe Brucker
in following patches. Cc: Eric Blake Cc: Markus Armbruster Cc: Daniel P. Berrangé Cc: Eduardo Habkost Acked-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Jean-Philippe Brucker --- v2->v3: remove some boilerplate w

[PATCH v3 07/26] target/arm/kvm: Create scratch VM as Realm if necessary

2024-11-25 Thread Jean-Philippe Brucker
to probe the VM's capabilities. Signed-off-by: Jean-Philippe Brucker --- target/arm/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index a0de2efc41..870f51bf02 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -106,6 +

Re: New "rme-guest" QEMU object addition

2024-11-21 Thread Jean-Philippe Brucker
Hi Itaru, On Thu, Nov 21, 2024 at 02:34:24PM +0900, Itaru Kitayama wrote: > Hi Jean, Mathieu, > > I’ve been using you guys’ ccs/v3 QEMU for some time to bring up an Realm > instance without a major issue, and as a one who is making changes libvirt to > support CCA, I wonder if you could merge t

Re: [PATCH v5 03/18] hw/arm/smmuv3: Fix encoding of CLASS in events

2024-07-17 Thread Jean-Philippe Brucker
Hi Eric, On Wed, Jul 17, 2024 at 05:07:57PM +0200, Eric Auger wrote: > Hi Jean, > > On 7/15/24 10:45, Mostafa Saleh wrote: > > The SMMUv3 spec (ARM IHI 0070 F.b - 7.3 Event records) defines the > > class of events faults as: > > > > CLASS: The class of the operation that caused the fault: > > - 0

Re: [PATCH v5 00/18] SMMUv3 nested translation support

2024-07-17 Thread Jean-Philippe Brucker
nested”, and > advertised to guests as (IDR0.S1P == 1 && IDR0.S2P == 2) For the whole series (3-9, 11, 12, 15, 16, 18): Reviewed-by: Jean-Philippe Brucker (and I think patch 16 is missing Eric's R-b)

Re: [PATCH v4 09/19] hw/arm/smmu-common: Rework TLB lookup for nesting

2024-07-09 Thread Jean-Philippe Brucker
On Tue, Jul 09, 2024 at 07:14:19AM +, Mostafa Saleh wrote: > Hi Jean, > > On Thu, Jul 04, 2024 at 07:12:35PM +0100, Jean-Philippe Brucker wrote: > > On Mon, Jul 01, 2024 at 11:02:31AM +, Mostafa Saleh wrote: > > > In the next patch, combine_tlb() will be ad

Re: [PATCH v4 08/19] hw/arm/smmuv3: Translate CD and TT using stage-2 table

2024-07-09 Thread Jean-Philippe Brucker
Hi Mostafa, On Tue, Jul 09, 2024 at 07:12:59AM +, Mostafa Saleh wrote: > > In this case I think we're reporting InputAddr as the CD address, but it > > should be the IOVA > > As Eric mentioned this would require some rework to propagate the iova, > but what I am more worried about is the read

Re: [PATCH v4 19/19] hw/arm/smmu: Refactor SMMU OAS

2024-07-04 Thread Jean-Philippe Brucker
o, it is easier just to change IDR5 and > it propagages correctly. > - Add additional checks when OAS is greater than 48bits. > - Remove unused functions/macros: pa_range/MAX_PA. > > Reviewed-by: Eric Auger > Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker

Re: [PATCH v4 18/19] hw/arm/smmuv3: Advertise S2FWB

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:40AM +, Mostafa Saleh wrote: > QEMU doesn's support memory attributes, so FWB is NOP, this > might change in the future if memory attributre would be supported. > > Signed-off-by: Mostafa Saleh > --- > hw/arm/smmuv3.c | 8 > 1 file changed, 8 insertions

Re: [PATCH v4 17/19] hw/arm/smmuv3: Support and advertise nesting

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:39AM +, Mostafa Saleh wrote: > Everything is in place, consolidate parsing of STE cfg and setting > translation stage. > > Advertise nesting if stage requested is "nested". > > Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philip

Re: [PATCH v4 16/19] hw/arm/smmuv3: Handle translation faults according to SMMUPTWEventInfo

2024-07-04 Thread Jean-Philippe Brucker
(cfg)->record_faults) || \ > +((ptw_info).stage == SMMU_STAGE_2 && > \ > + (cfg)->s2cfg.record_faults)) I guess this could be simplified as "(info.stage == STAGE_1)

Re: [PATCH v4 15/19] hw/arm/smmuv3: Support nested SMMUs in smmuv3_notify_iova()

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:37AM +, Mostafa Saleh wrote: > IOMMUTLBEvent only understands IOVA, for stage-1 or stage-2 > SMMU instances we consider the input address as the IOVA, but when > nesting is used, we can't mix stage-1 and stage-2 addresses, so for > nesting only stage-1 is considere

Re: [PATCH v4 14/19] hw/arm/smmu: Support nesting in the rest of commands

2024-07-04 Thread Jean-Philippe Brucker
rted, otherwise > invalidate everything, this required a new vmid invalidation > function for stage-1 only (ASID >= 0) > > Also, rework trace events to reflect the new implementation. > > Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker > -

Re: [PATCH v4 13/19] hw/arm/smmu: Introduce smmu_iotlb_inv_asid_vmid

2024-07-04 Thread Jean-Philippe Brucker
isn't bisectable. Reviewed-by: Jean-Philippe Brucker > --- > hw/arm/smmu-common.c | 20 +--- > hw/arm/smmuv3.c | 2 +- > include/hw/arm/smmu-common.h | 2 +- > 3 files changed, 15 insertions(+), 9 deletions(-) > > diff --git

Re: [PATCH v4 12/19] hw/arm/smmu: Support nesting in smmuv3_range_inval()

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:34AM +, Mostafa Saleh wrote: > With nesting, we would need to invalidate IPAs without > over-invalidating stage-1 IOVAs. This can be done by > distinguishing IPAs in the TLBs by having ASID=-1. > To achieve that, rework the invalidation for IPAs to have a > separat

Re: [PATCH v4 11/19] hw/arm/smmu-common: Support nested translation

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:33AM +, Mostafa Saleh wrote: > When nested translation is requested, do the following: > > - Translate stage-1 table address IPA into PA through stage-2. > - Translate stage-1 table walk output (IPA) through stage-2. > - Create a single TLB entry from stage-1 and

Re: [PATCH v4 10/19] hw/arm/smmu-common: Add support for nested TLB

2024-07-04 Thread Jean-Philippe Brucker
ova that would be cached is recalculated. >- Translated_addr is chosen from stage-2. > > Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker > --- > hw/arm/smmu-common.c | 37 > include/hw/arm/smmu-common.h | 1 + >

Re: [PATCH v4 09/19] hw/arm/smmu-common: Rework TLB lookup for nesting

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:31AM +, Mostafa Saleh wrote: > In the next patch, combine_tlb() will be added which combines 2 TLB > entries into one for nested translations, which chooses the granule > and level from the smallest entry. > > This means that with nested translation, an entry can

Re: [PATCH v4 08/19] hw/arm/smmuv3: Translate CD and TT using stage-2 table

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:30AM +, Mostafa Saleh wrote: > According to ARM SMMU architecture specification (ARM IHI 0070 F.b), > In "5.2 Stream Table Entry": > [51:6] S1ContextPtr > If Config[1] == 1 (stage 2 enabled), this pointer is an IPA translated by > stage 2 and the programmed valu

Re: [PATCH v4 07/19] hw/arm/smmu: Introduce CACHED_ENTRY_TO_ADDR

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:29AM +, Mostafa Saleh wrote: > Soon, smmuv3_do_translate() will be used to translate the CD and the > TTBx, instead of re-writting the same logic to convert the returned > cached entry to an address, add a new macro CACHED_ENTRY_TO_ADDR. > > Signed-off-by: Mostafa

Re: [PATCH v4 03/19] hw/arm/smmuv3: Fix encoding of CLASS in events

2024-07-04 Thread Jean-Philippe Brucker
On Mon, Jul 01, 2024 at 11:02:25AM +, Mostafa Saleh wrote: > The SMMUv3 spec (ARM IHI 0070 F.b - 7.3 Event records) defines the > class of events faults as: > > CLASS: The class of the operation that caused the fault: > - 0b00: CD, CD fetch. > - 0b01: TTD, Stage 1 translation table fetch. > -

Re: [PATCH v4 02/19] hw/arm/smmu: Fix IPA for stage-2 events

2024-07-04 Thread Jean-Philippe Brucker
rm/smmuv3: Add page table walk for stage-2” > Reviewed-by: Eric Auger > Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker > --- > hw/arm/smmu-common.c | 10 ++ > hw/arm/smmuv3.c | 4 > 2 files changed, 10 insertions(+), 4 deletions(-) >

Re: [PATCH v4 01/19] hw/arm/smmu-common: Add missing size check for stage-1

2024-07-04 Thread Jean-Philippe Brucker
ive IPA size for the given CD. > > However, this check was missing. > > There is already a similar check for stage-2 against effective PA. > > Reviewed-by: Eric Auger > Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker > --- > hw/arm/smmu-common.

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-06-06 Thread Jean-Philippe Brucker
On Thu, Jun 06, 2024 at 03:05:02PM +1000, Gavin Shan wrote: > > This commit moves the page tables from .rodata to .data. When linking > > IdMap.obj into ArmPlatformPrePeiCore.dll, the alignment of the .text > > section changes from 0x1000 to 0x800. This change comes from the linker > > script putti

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-06-05 Thread Jean-Philippe Brucker
On Wed, Jun 05, 2024 at 11:28:47AM +1000, Gavin Shan wrote: > > >WriteSections64(): > > > /home/gavin/sandbox/CCA/edk2-guest/Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore/DEBUG/ArmPlatformPrePeiCore.dll > > > AARCH64 small code model requires identic

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-06-04 Thread Jean-Philippe Brucker
On Fri, May 31, 2024 at 05:24:44PM +0200, Ard Biesheuvel wrote: > > I'm able to reproduce this even without RME. This code was introduced > > recently by c98f7f755089 ("ArmVirtPkg: Use dynamic PCD to set the SMCCC > > conduit"). Maybe Ard (Cc'd) knows what could be going wrong here. > > > > A sligh

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-06-04 Thread Jean-Philippe Brucker
Hi Gavin, On Tue, Jun 04, 2024 at 01:02:08PM +1000, Gavin Shan wrote: > Hi Jean, > > On 6/3/24 18:24, Jean-Philippe Brucker wrote: > > On Sat, Jun 01, 2024 at 08:14:46PM +1000, Gavin Shan wrote: > > > ---> guest edk2 > > > > > > # git clone https:/

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-06-03 Thread Jean-Philippe Brucker
Hi Gavin, On Sat, Jun 01, 2024 at 08:14:46PM +1000, Gavin Shan wrote: > ---> guest edk2 > > # git clone https://git.codelinaro.org/linaro/dcap/edk2.git edk2-guest > # cd edk2-guest; git checkout origin/cca/v2 -b cca/v2 > # git submodule update --init --recursive; \ > source edksetup.sh; make -

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-05-31 Thread Jean-Philippe Brucker
On Fri, May 31, 2024 at 11:16:30PM +0900, Itaru Kitayama wrote: > Thanks! I wasn’t aware of it The good news is that after whole day of try and > error attempts I was able to > bring up a Realm VM on FVP. Here’s my version of overlay yaml, cca-v2.yaml: That is good news, thanks for the update >

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-05-31 Thread Jean-Philippe Brucker
Hi Gavin, On Fri, May 31, 2024 at 04:23:13PM +1000, Gavin Shan wrote: > I got a chance to try CCA software components, suggested by [1]. However, the > edk2 > is stuck somewhere. I didn't reach to stage of loading guest kernel yet. I'm > replying > to see if anyone has a idea. ... > INFO:BL3

Re: Unexpected error in rme_configure_one() at ../target/arm/kvm-rme.c:159

2024-05-31 Thread Jean-Philippe Brucker
Hi Itaru, On Fri, May 31, 2024 at 10:57:13AM +0100, Peter Maydell wrote: > On Fri, 31 May 2024 at 05:20, Itaru Kitayama wrote: > > > > > > > > > On May 30, 2024, at 22:30, Philippe Mathieu-Daudé > > > wrote: > > > > > > Cc'ing more developers > > > > > > On 30/5/24 06:30, Itaru Kitayama wrote:

Re: [PATCH v2 02/22] target/arm: Add confidential guest support

2024-04-23 Thread Jean-Philippe Brucker
On Fri, Apr 19, 2024 at 05:25:12PM +0100, Daniel P. Berrangé wrote: > On Fri, Apr 19, 2024 at 04:56:50PM +0100, Jean-Philippe Brucker wrote: > > Add a new RmeGuest object, inheriting from ConfidentialGuestSupport, to > > support the Arm Realm Management Extension (RME). It is

[PATCH v2 06/22] hw/arm/virt: Disable DTB randomness for confidential VMs

2024-04-19 Thread Jean-Philippe Brucker
Currently the feature is automatically enabled, unless the user disables it on the command-line. Change it to OnOffAuto, and automatically disable it for confidential VMs, unless the user explicitly enables it. Signed-off-by: Jean-Philippe Brucker --- v1->v2: separate patch, use OnOffAuto --

[PATCH v2 18/22] target/arm/kvm: Disable Realm reboot

2024-04-19 Thread Jean-Philippe Brucker
EMU to crash with a bus error. Handle reboot requests by the guest more gracefully, by indicating to runstate.c that the vCPUs of a Realm are not resettable, and that QEMU should exit. Reviewed-by: Richard Henderson Signed-off-by: Jean-Philippe Brucker --- target/arm/kvm.c | 3 ++- 1 file chan

[PATCH v2 19/22] target/arm/cpu: Inform about reading confidential CPU registers

2024-04-19 Thread Jean-Philippe Brucker
The host cannot access registers of a Realm. Instead of showing all registers as zero in "info registers", display a message about this restriction. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- target/arm/cpu.c | 5 + 1 file changed, 5 insertions(+) diff --git

[PATCH v2 13/22] hw/arm/boot: Register Linux BSS section for confidential guests

2024-04-19 Thread Jean-Philippe Brucker
regression of 2.8ms on a fast desktop, 5.7% of the QEMU setup time). On a slower host, the regression could be much larger. Instead, add a special case to initialize the kernel's BSS IPA range. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- target/arm/kvm_arm.h | 5 + hw/ar

[PATCH v2 15/22] target/arm/kvm-rme: Add measurement algorithm property

2024-04-19 Thread Jean-Philippe Brucker
pport acceleration via FEAT_SHA256 (Armv8.0) and not FEAT_SHA512 (Armv8.2). Future CPUs supporting RME are likely to also support FEAT_SHA512. Cc: Eric Blake Cc: Markus Armbruster Cc: Daniel P. Berrangé Cc: Eduardo Habkost Signed-off-by: Jean-Philippe Brucker --- v1->v2: use enum, pick

[PATCH v2 04/22] target/arm/kvm-rme: Initialize realm

2024-04-19 Thread Jean-Philippe Brucker
which point the realm is sealed. Signed-off-by: Jean-Philippe Brucker --- v1->v2: * Use g_assert_not_reached() in stubs * Init from kvm_arch_init() rather than hw/arm/virt * Cache rme_guest --- target/arm/kvm_arm.h | 16 +++ target/arm/kvm-rme.c |

[PATCH v2 09/22] target/arm/kvm-rme: Initialize vCPU

2024-04-19 Thread Jean-Philippe Brucker
KVM_GET_REG_LIST. Signed-off-by: Jean-Philippe Brucker --- v1->v2: only do the GP regs, since they are sync'd explicitly. Other registers use the existing reglist facility. --- target/arm/cpu.h | 3 +++ target/arm/kvm_arm.h | 1 + target/arm/kvm-rme.c | 10 target/arm/kvm.c

[PATCH v2 16/22] target/arm/cpu: Set number of breakpoints and watchpoints in KVM

2024-04-19 Thread Jean-Philippe Brucker
and watchpoints, and influence the Realm Initial Measurement. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- target/arm/cpu.h | 4 ++ target/arm/kvm_arm.h | 2 + target/arm/arm-qmp-cmds.c | 1 + target/arm/cpu64.c| 77 ++

[PATCH v2 11/22] hw/core/loader: Add ROM loader notifier

2024-04-19 Thread Jean-Philippe Brucker
attestation. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- include/hw/loader.h | 15 +++ hw/core/loader.c| 15 +++ 2 files changed, 30 insertions(+) diff --git a/include/hw/loader.h b/include/hw/loader.h index 8685e27334..79fab25dd9 100644 --- a/include

[PATCH v2 21/22] hw/arm/virt: Move virt_flash_create() to machvirt_init()

2024-04-19 Thread Jean-Philippe Brucker
ine->cgs member. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- hw/arm/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index eca9a96b5a..bed19d0b79 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2071,6 +2071,8

[PATCH v2 12/22] target/arm/kvm-rme: Populate Realm memory

2024-04-19 Thread Jean-Philippe Brucker
Collect the images copied into guest RAM into a sorted list, and issue POPULATE_REALM KVM ioctls once we've created the Realm Descriptor. The images are part of the Realm Initial Measurement. Signed-off-by: Jean-Philippe Brucker --- v1->v2: Use a ROM loader notifier --- target/arm/k

[PATCH v2 17/22] target/arm/cpu: Set number of PMU counters in KVM

2024-04-19 Thread Jean-Philippe Brucker
Add a "num-pmu-counters" CPU parameter to configure the number of counters that KVM presents to the guest. This is needed for Realm VMs, whose parameters include the number of PMU counters and influence the Realm Initial Measurement. Signed-off-by: Jean-Philippe Brucker --- v

[PATCH v2 20/22] target/arm/kvm-rme: Enable guest memfd

2024-04-19 Thread Jean-Philippe Brucker
se ms->require_guest_memfd is not yet merged. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- target/arm/kvm-rme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/kvm-rme.c b/target/arm/kvm-rme.c index 8f39e54aaa..71cc1d4147 100644 --- a/target/arm/kvm-rme.c +++ b/target/arm/kvm-rme.

[PATCH v2 22/22] hw/arm/virt: Use RAM instead of flash for confidential guest firmware

2024-04-19 Thread Jean-Philippe Brucker
e any information to the host, hence will not store its variables in clear persistent memory. We can therefore replace the flash device with RAM, and load the firmware there. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- include/hw/arm/boot.h | 9 + hw/arm/boot.c

[PATCH v2 00/22] arm: Run CCA VMs with KVM

2024-04-19 Thread Jean-Philippe Brucker
/20240322181116.1228416-1-pbonz...@redhat.com/ Jean-Philippe Brucker (22): kvm: Merge kvm_check_extension() and kvm_vm_check_extension() target/arm: Add confidential guest support target/arm/kvm: Return immediately on error in kvm_arch_init() target/arm/kvm-rme: Initialize realm hw/arm/virt: Add support

[PATCH v2 03/22] target/arm/kvm: Return immediately on error in kvm_arch_init()

2024-04-19 Thread Jean-Philippe Brucker
Returning an error to kvm_init() is fatal anyway, no need to continue the initialization. Signed-off-by: Jean-Philippe Brucker --- v1->v2: new --- target/arm/kvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 3371ffa

[PATCH v2 01/22] kvm: Merge kvm_check_extension() and kvm_vm_check_extension()

2024-04-19 Thread Jean-Philippe Brucker
kernel.org/kvm/875ybi0ytc@redhat.com/ [3] https://github.com/torvalds/linux/commit/92b591a4c46b Cc: Marcelo Tosatti Cc: Nicholas Piggin Cc: Daniel Henrique Barboza Cc: qemu-...@nongnu.org Suggested-by: Cornelia Huck Signed-off-by: Jean-Philippe Brucker --- v1: https://lore.kernel.org/

[PATCH v2 14/22] target/arm/kvm-rme: Add Realm Personalization Value parameter

2024-04-19 Thread Jean-Philippe Brucker
. Berrangé Cc: Eduardo Habkost Signed-off-by: Jean-Philippe Brucker --- v1->v2: Move parsing early, store as-is rather than reverted --- qapi/qom.json| 15 +- target/arm/kvm-rme.c | 111 +++ 2 files changed, 125 insertions(+), 1 delet

[PATCH v2 05/22] hw/arm/virt: Add support for Arm RME

2024-04-19 Thread Jean-Philippe Brucker
When confidential-guest-support is enabled for the virt machine, call the RME init function, and add the RME flag to the VM type. Signed-off-by: Jean-Philippe Brucker --- v1->v2: * Don't explicitly disable steal_time, it's now done through KVM capabilities * Split patch --- hw/ar

[PATCH v2 07/22] hw/arm/virt: Reserve one bit of guest-physical address for RME

2024-04-19 Thread Jean-Philippe Brucker
When RME is enabled, the upper GPA bit is used to distinguish protected from unprotected addresses. Reserve it when setting up the guest memory map. Signed-off-by: Jean-Philippe Brucker --- v1->v2: separate patch --- hw/arm/virt.c | 14 -- 1 file changed, 12 insertions(+)

[PATCH v2 10/22] target/arm/kvm: Create scratch VM as Realm if necessary

2024-04-19 Thread Jean-Philippe Brucker
to probe the VM's capabilities. KVM only reports the maximum IPA it supports, but RMM may support smaller sizes. If the VM creation fails with the value returned by KVM, then retry with the smaller working address. This needs a better solution. Signed-off-by: Jean-Philippe Brucker --- targe

[PATCH v2 08/22] target/arm/kvm: Split kvm_arch_get/put_registers

2024-04-19 Thread Jean-Philippe Brucker
The confidential guest support in KVM limits the number of registers that we can read and write. Split the get/put_registers function to prepare for it. Signed-off-by: Jean-Philippe Brucker --- target/arm/kvm.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions

  1   2   3   4   5   6   >