From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 730AF2AF1D for ; Thu, 2 Oct 2025 05:16:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759382205; cv=none; b=q4iEVk73FhZuKx/Z60TsLY8sSJbGrFUj8qjMsyjThJKBcPRytRX+TNWAEjbDZMJjhdiNaaKMGnHIuYIkYl6UvFCMHn71CMjYMT6jJN18PNPpddGUx7iDpI3vcf6uKHdCGw756tWpaPjli93MOmluUncR0F+ZydCSKrFhFCT9AmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759382205; c=relaxed/simple; bh=uLxLwFOE/rQGNhrBcHl0yxHQQEm07KXFtX9lK1L5xIc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eDczVzrtFmq3zBqx4YiFw0sa++4W/J95wGlhMEwIe/rpfwM+TwhBil1PIHK9x8mwDBK9tU0B5Jita1OJRi4xMvnD9fstiTZKF9tlAbHzX5mbYQ0026FyiE20nSOJbO1j27Bz5B07orllERy9ACFHokUz5lTC1DRi++wGDVNB/s8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=gx2yPDYz; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gx2yPDYz" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-46e2e6a708fso3202225e9.0 for ; Wed, 01 Oct 2025 22:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1759382202; x=1759987002; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=nP44d4h1jekHn6mFqnHJmhmS/9Do5wl9GUaQdd3lrCA=; b=gx2yPDYzjnOUYff5czycMnSucYvN33t29IEMGCzdodhWAk/fqkOiNa4a2El2myD0u0 vQlxnYXaq6OysY56lZuqhqx0OnB77STPIlD8HlYG/RGNZ0bh7ioLJIIjUopXzM7SEvAs c+1q1760nAiMjt7gMrkkSeAGMyYDVIJ5Cs2d18qMbHUVfDwr5OBio+uX7QkFTd6lcx0z OSskkF0xKBXRLz23jMDhnsrMBENyu5m5QgrH75R5GTC/apzGLjgy2BDraleL7a2ukQsS FhIAx1fCOTyU2adHHLMUTfyIYv9XcJzGSqJhRJkAxEB6umG4QKb3NNvW1JNmloalU2JL tqmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759382202; x=1759987002; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nP44d4h1jekHn6mFqnHJmhmS/9Do5wl9GUaQdd3lrCA=; b=XdhqEvZzNgpxhYzQ9qhCpWFqm91FG7uVIyRVylVNnGUXL8A3cSbPCNjQcT+u0EqWlB ZjRjE6YVmybxxbeGG7hj/BXPeIa5hdpNkrWRwqLSbXK6d/M2PAtQw2DhMlwzg7y8k0RM tEUM18LMZwWd3BsQ6TtI+RpMaX088fzbovUbJ494KnW1XuNAXIvecxVJBNqlT0fxQ6Wg tv8L8Roo3Ut0N4VRhvSAlO2LAJWHJ/R2JvMmjhy8Td6U8CzGcPvmC6XIj3W5DrH3hkt3 GhFLqTSUPIxK8d/WQ8npzZYXzqRw7xyJf4qYQOtNacYCq6CHTkcSD/n1GwY2/8f7XYp2 YAQA== X-Forwarded-Encrypted: i=1; AJvYcCWkKcQ3cnqUBSRShYuzos98a4/gQg1g4HkjxTtRc4ZhAx8yycEkEUdWFFOkLdK3adTmm5o=@vger.kernel.org X-Gm-Message-State: AOJu0YzeiWSAgiAeN04r+i0knG3ahSqivzDdER1SUhf1pzvhijhO58G8 ZUgTvcaEomRket5+eFg9IlGeH2Bj/nam33VpLuRucu2yYUhYCLxmTlgo51ng9ztMXaA= X-Gm-Gg: ASbGncslosCVVms7FDv/nkXInZPVUcCgFZfsNiBg6huVD97sHy3EwrtNO9rn4JbkF2A 52ya0qI9Id/YNtDlvhamyHNjA2bqP80CbDz7IgYlfv7CGtwCTNGBRzl3b8fLyx1R84DcGV6fB4S VloLvkS7g5CdKY28GRYSL9bKBpCJ0r/dLbRddKFNJpjWAHleiunnFchxfLFxGuOhSoc/lYFo9aa tUkm+Ssbhof32EwHCall8YexQnmjiFTiKEt8l7EPIKU1zbqM5+fsirWZY9XqY9J3C/2He5yxDX2 qo0cZfIns8mBD8rAa8ZCB2Pv5AfT9v3u1j0w8WVJOY/8luAITaD5oJCjzHUlSIY5/pHGCq/nef1 Fz7TjM92BulAk/OrjqEVxxgoHmoxw9nywXDAJ3m1YCqlyEM/zGb3QxEGPFrEn6KKq8AYTtfpDhP f+2Us68Ag4IMuxK/IrEmwSuFk= X-Google-Smtp-Source: AGHT+IFTCkFMkkXlWMIq3Vgvzt5IFWI271cdWtVJqy/RZz/1PwzpzG3SNgfPDaXsmuZn+VswPUUmHA== X-Received: by 2002:a05:600c:3544:b0:46e:5df4:6f16 with SMTP id 5b1f17b1804b1-46e61294d1emr46097095e9.35.1759382201614; Wed, 01 Oct 2025 22:16:41 -0700 (PDT) Received: from [192.168.69.221] (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a022d8sm62129355e9.12.2025.10.01.22.16.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Oct 2025 22:16:41 -0700 (PDT) Message-ID: Date: Thu, 2 Oct 2025 07:16:39 +0200 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 12/23] whpx: copy over memory management logic from hvf Content-Language: en-US To: Mohamed Mediouni , qemu-devel@nongnu.org, Richard Henderson Cc: Shannon Zhao , Yanan Wang , Phil Dennis-Jordan , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , =?UTF-8?Q?Marc-Andr=C3=A9_Lureau?= , Mads Ynddal , Cameron Esfahani , Paolo Bonzini , Zhao Liu , "Michael S. Tsirkin" , kvm@vger.kernel.org, Igor Mammedov , qemu-arm@nongnu.org, Roman Bolshakov , Pedro Barbuda , Alexander Graf , Sunil Muthuswamy , Eduardo Habkost , Ani Sinha , Marcel Apfelbaum , Peter Maydell , Pierrick Bouvier References: <20250920140124.63046-1-mohamed@unpredictable.fr> <20250920140124.63046-13-mohamed@unpredictable.fr> From: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= In-Reply-To: <20250920140124.63046-13-mohamed@unpredictable.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 20/9/25 16:01, Mohamed Mediouni wrote: > This allows edk2 to work, although u-boot is still not functional. > > Signed-off-by: Mohamed Mediouni > > Reviewed-by: Pierrick Bouvier > --- > accel/whpx/whpx-common.c | 201 ++++++++++++++++++++++++++++----------- > 1 file changed, 147 insertions(+), 54 deletions(-) > > diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c > index c69792e638..f324f5c146 100644 > --- a/accel/whpx/whpx-common.c > +++ b/accel/whpx/whpx-common.c > @@ -258,89 +258,174 @@ void whpx_vcpu_kick(CPUState *cpu) > * Memory support. > */ > > -static void whpx_update_mapping(hwaddr start_pa, ram_addr_t size, > - void *host_va, int add, int rom, > - const char *name) > + /* whpx_slot flags */ > +#define WHPX_SLOT_LOG (1 << 0) > +typedef struct whpx_slot { > + uint64_t start; > + uint64_t size; > + uint8_t *mem; > + int slot_id; > + uint32_t flags; > + MemoryRegion *region; > +} whpx_slot; > + > +typedef struct WHPXState { > + whpx_slot slots[32]; > + int num_slots; > +} WHPXState; > + > + WHPXState *whpx_state; > + > + struct mac_slot { > + int present; > + uint64_t size; > + uint64_t gpa_start; > + uint64_t gva; > +}; > + > +struct mac_slot mac_slots[32]; > + > +static int do_whpx_set_memory(whpx_slot *slot, WHV_MAP_GPA_RANGE_FLAGS flags) > { > struct whpx_state *whpx = &whpx_global; > + struct mac_slot *macslot; > HRESULT hr; > > - /* > - if (add) { > - printf("WHPX: ADD PA:%p Size:%p, Host:%p, %s, '%s'\n", > - (void*)start_pa, (void*)size, host_va, > - (rom ? "ROM" : "RAM"), name); > - } else { > - printf("WHPX: DEL PA:%p Size:%p, Host:%p, '%s'\n", > - (void*)start_pa, (void*)size, host_va, name); > + macslot = &mac_slots[slot->slot_id]; > + > + if (macslot->present) { > + if (macslot->size != slot->size) { > + macslot->present = 0; > + hr = whp_dispatch.WHvUnmapGpaRange(whpx->partition, > + macslot->gpa_start, macslot->size); > + if (FAILED(hr)) { > + abort(); > + } > + } > } > - */ > - > - if (add) { > - hr = whp_dispatch.WHvMapGpaRange(whpx->partition, > - host_va, > - start_pa, > - size, > - (WHvMapGpaRangeFlagRead | > - WHvMapGpaRangeFlagExecute | > - (rom ? 0 : WHvMapGpaRangeFlagWrite))); > - } else { > - hr = whp_dispatch.WHvUnmapGpaRange(whpx->partition, > - start_pa, > - size); > + > + if (!slot->size) { > + return 0; > } > > - if (FAILED(hr)) { > - error_report("WHPX: Failed to %s GPA range '%s' PA:%p, Size:%p bytes," > - " Host:%p, hr=%08lx", > - (add ? "MAP" : "UNMAP"), name, > - (void *)(uintptr_t)start_pa, (void *)size, host_va, hr); > + macslot->present = 1; > + macslot->gpa_start = slot->start; > + macslot->size = slot->size; > + hr = whp_dispatch.WHvMapGpaRange(whpx->partition, > + slot->mem, slot->start, slot->size, flags); > + return 0; > +} [...] This HVF code is bogus and Richard has been heavily reworking it. We haven't posted the changes so far, but IMHO it is worth waiting them to compare before proceeding with this series. I'll let Richard briefly explain what we had to change ;) Regards, Phil.