From nobody Fri Apr 4 11:48:58 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1741243447; cv=none; d=zohomail.com; s=zohoarc; b=WWgPOMgM0eHEt93iYwJ8lQUfWsh6NPY4NpPw+l/N3exVOSmSflxMbc52mhyLv686K4CIfKnyHvihkTRCvSL+ZDg+83LzUuXlSpjuwxhIn6iBYuQ557g4t/6kRaKTiA+lhDrtafdYIhdqyn0ELOwSr3hNmolPE04qKX2goYopDZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741243447; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a4g6UCTPF7xt6XmRoqdLfJpuJ3HLau+yVZ65YGfmCxA=; b=Tv3YzEsvfHLqH+c32wode60n/o4nlK0ayZ+RlvjcSNbdlO548OJytMuH/5xyhpCE8z7G2TQjRipSvySIuHbKhOCHIQig/JotZPQbY6pFr9PVilzVSG6tzxPVEofqW+BzeeWMc5Iij07CTtpEEis5RWiW9U8Mk1tgd0GkIuHtamk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from=<pierrick.bouvier@linaro.org> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741243447767219.47070054005053; Wed, 5 Mar 2025 22:44:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tq4vO-00021I-2Y; Thu, 06 Mar 2025 01:41:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <pierrick.bouvier@linaro.org>) id 1tq4vF-0001zH-Re for qemu-devel@nongnu.org; Thu, 06 Mar 2025 01:41:35 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <pierrick.bouvier@linaro.org>) id 1tq4vC-0006FU-GZ for qemu-devel@nongnu.org; Thu, 06 Mar 2025 01:41:32 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2234e4b079cso3859325ad.1 for <qemu-devel@nongnu.org>; Wed, 05 Mar 2025 22:41:30 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22410a91cffsm4769355ad.174.2025.03.05.22.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Mar 2025 22:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741243289; x=1741848089; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a4g6UCTPF7xt6XmRoqdLfJpuJ3HLau+yVZ65YGfmCxA=; b=Y3Q1JP9AhdFAZFVWGWctlb2h5XjyWxwXSOfceKHGgHz+ZRROJii4KmEq9mAc3WRzaQ sLZME/9oX7KiWnkitUB7+orO7FQvvkgFFh6VqkndrdLvJxV/xZZutPy1q96xJjkgVj4Y +xWjwSaWS21Gp7luO2RVfow+RXKI5WZ1gIC1gGYSt9ZAjYMa2aRW+o0LsZMENpQdZufU 1YDDBHPyEanbLuphph/rK8eGZpOXtgWZykyzfeude3GKxK8XQWTFKcg2CKHnWhjWjUSf ZrYJvXoh5rVtiGbfa+zta7YpRjmS901L8hT2kfeFqNBwLGp9uRSYC8WTCbnuM49Rqzee 3BIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741243289; x=1741848089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a4g6UCTPF7xt6XmRoqdLfJpuJ3HLau+yVZ65YGfmCxA=; b=fVwVXmLgD7hDBbnJ1b1vfYace3HrpoE93SaRMkFQukNwDkO7+OKRqkIWpE71IKvjlg cRxwY2s7T+yJTxjqNpjJ6rDtmqADcBLSSwl0iOHMXqZDHCbei6mlQtBHtONQtsehjDOT /UWIMkoVUdCpP7AojVDSCU4B4w5uDlmwiYQJOzzddcgHWeYoyo6A97vcEzNn2tYK0oBA bvxnKdpQUx0UyKWyiBBZHCqS9d7YmhhfJA0nJhJ6YnTsTbjmM00icttb1vlJVBIQCg5R cM4Ts2EeOheQQi6X59gQUc1se1+V47STSGudh7G9JJ3TvrH00tdtdkTLcor9BQQpBZt3 4A+A== X-Gm-Message-State: AOJu0YzyUUfdwyUyVkSZF/UWPoydB6TLHeW6Xyc3bkYKonSMqQuTn3L+ 9QqEO3Rju/ONYLyIO/wMz8Ar4NCb923LD9375OgdLP3rgRxCQWqfcjO6Q/Kz2mWVyWEpS8hHMqn z X-Gm-Gg: ASbGncshut/Owl6B8tsWhfGgWyn1h27cxkKm1RnBaWMXYSntj3ZZ1f9sHJtvcbGzLpS lpqpFpH/Psx2D0oq2IhuHHwhozTT06xPqBfcFg5ajAjw8C6X772A5AwO+xMVaqeQ8/G31dxRS1f u3xujIyE/BN0WHiyYsNJ9rlvppbo3M7DA7opxQWlEKdA7y2Wm+5v1/VjNsUJw0j/IwG8NSSLfHr lR4obFpqeABBs4C0KmpuqAb7eRfFKU9gOjOtLDJlme+FOo1BBObnOsLhqkc70G18oLyBzmKwqi+ AF2YiPEu4uZCDw5g9sChJIpHq9bJ0sQL/uWd/S+8LCEd X-Google-Smtp-Source: AGHT+IGfAiV2y2sV/+twWgPqy3JAP1CBHCKmg3Dbm9uDmHILN+zHI1fLgqUtIpvFbzvqC1JioNGrKw== X-Received: by 2002:a17:903:3ba5:b0:21f:ba77:c45e with SMTP id d9443c01a7336-223f1d81964mr88722495ad.45.1741243288953; Wed, 05 Mar 2025 22:41:28 -0800 (PST) From: Pierrick Bouvier <pierrick.bouvier@linaro.org> To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, philmd@linaro.org, Paolo Bonzini <pbonzini@redhat.com>, pierrick.bouvier@linaro.org, manos.pitsidianakis@linaro.org, "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>, richard.henderson@linaro.org, Marcelo Tosatti <mtosatti@redhat.com>, alex.bennee@linaro.org Subject: [PATCH 3/7] hw/hyperv/vmbus: common compilation unit Date: Wed, 5 Mar 2025 22:41:14 -0800 Message-Id: <20250306064118.3879213-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250306064118.3879213-1-pierrick.bouvier@linaro.org> References: <20250306064118.3879213-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1741243450160019100 Content-Type: text/plain; charset="utf-8" Replace TARGET_PAGE.* by runtime calls. Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> --- hw/hyperv/vmbus.c | 50 +++++++++++++++++++++---------------------- hw/hyperv/meson.build | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index 12a7dc43128..109ac319caf 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -18,7 +18,7 @@ #include "hw/hyperv/vmbus.h" #include "hw/hyperv/vmbus-bridge.h" #include "hw/sysbus.h" -#include "cpu.h" +#include "exec/target_page.h" #include "trace.h" =20 enum { @@ -309,7 +309,7 @@ void vmbus_put_gpadl(VMBusGpadl *gpadl) =20 uint32_t vmbus_gpadl_len(VMBusGpadl *gpadl) { - return gpadl->num_gfns * TARGET_PAGE_SIZE; + return gpadl->num_gfns * qemu_target_page_size(); } =20 static void gpadl_iter_init(GpadlIter *iter, VMBusGpadl *gpadl, @@ -323,14 +323,14 @@ static void gpadl_iter_init(GpadlIter *iter, VMBusGpa= dl *gpadl, =20 static inline void gpadl_iter_cache_unmap(GpadlIter *iter) { - uint32_t map_start_in_page =3D (uintptr_t)iter->map & ~TARGET_PAGE_MAS= K; - uint32_t io_end_in_page =3D ((iter->last_off - 1) & ~TARGET_PAGE_MASK)= + 1; + uint32_t map_start_in_page =3D (uintptr_t)iter->map & ~qemu_target_pag= e_mask(); + uint32_t io_end_in_page =3D ((iter->last_off - 1) & ~qemu_target_page_= mask()) + 1; =20 /* mapping is only done to do non-zero amount of i/o */ assert(iter->last_off > 0); assert(map_start_in_page < io_end_in_page); =20 - dma_memory_unmap(iter->as, iter->map, TARGET_PAGE_SIZE - map_start_in_= page, + dma_memory_unmap(iter->as, iter->map, qemu_target_page_size() - map_st= art_in_page, iter->dir, io_end_in_page - map_start_in_page); } =20 @@ -348,17 +348,17 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *b= uf, uint32_t len) assert(iter->active); =20 while (len) { - uint32_t off_in_page =3D iter->off & ~TARGET_PAGE_MASK; - uint32_t pgleft =3D TARGET_PAGE_SIZE - off_in_page; + uint32_t off_in_page =3D iter->off & ~qemu_target_page_mask(); + uint32_t pgleft =3D qemu_target_page_size() - off_in_page; uint32_t cplen =3D MIN(pgleft, len); void *p; =20 /* try to reuse the cached mapping */ if (iter->map) { uint32_t map_start_in_page =3D - (uintptr_t)iter->map & ~TARGET_PAGE_MASK; - uint32_t off_base =3D iter->off & ~TARGET_PAGE_MASK; - uint32_t mapped_base =3D (iter->last_off - 1) & ~TARGET_PAGE_M= ASK; + (uintptr_t)iter->map & ~qemu_target_page_mask(); + uint32_t off_base =3D iter->off & ~qemu_target_page_mask(); + uint32_t mapped_base =3D (iter->last_off - 1) & ~qemu_target_p= age_mask(); if (off_base !=3D mapped_base || off_in_page < map_start_in_pa= ge) { gpadl_iter_cache_unmap(iter); iter->map =3D NULL; @@ -368,10 +368,10 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *b= uf, uint32_t len) if (!iter->map) { dma_addr_t maddr; dma_addr_t mlen =3D pgleft; - uint32_t idx =3D iter->off >> TARGET_PAGE_BITS; + uint32_t idx =3D iter->off >> qemu_target_page_bits(); assert(idx < iter->gpadl->num_gfns); =20 - maddr =3D (iter->gpadl->gfns[idx] << TARGET_PAGE_BITS) | off_i= n_page; + maddr =3D (iter->gpadl->gfns[idx] << qemu_target_page_bits()) = | off_in_page; =20 iter->map =3D dma_memory_map(iter->as, maddr, &mlen, iter->dir, MEMTXATTRS_UNSPECIFIED); @@ -382,7 +382,7 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *buf= , uint32_t len) } } =20 - p =3D (void *)(uintptr_t)(((uintptr_t)iter->map & TARGET_PAGE_MASK= ) | + p =3D (void *)(uintptr_t)(((uintptr_t)iter->map & qemu_target_page= _mask()) | off_in_page); if (iter->dir =3D=3D DMA_DIRECTION_FROM_DEVICE) { memcpy(p, buf, cplen); @@ -591,9 +591,9 @@ static void ringbuf_init_common(VMBusRingBufCommon *rin= gbuf, VMBusGpadl *gpadl, uint32_t begin, uint32_t end) { ringbuf->as =3D as; - ringbuf->rb_addr =3D gpadl->gfns[begin] << TARGET_PAGE_BITS; - ringbuf->base =3D (begin + 1) << TARGET_PAGE_BITS; - ringbuf->len =3D (end - begin - 1) << TARGET_PAGE_BITS; + ringbuf->rb_addr =3D gpadl->gfns[begin] << qemu_target_page_bits(); + ringbuf->base =3D (begin + 1) << qemu_target_page_bits(); + ringbuf->len =3D (end - begin - 1) << qemu_target_page_bits(); gpadl_iter_init(&ringbuf->iter, gpadl, as, dir); } =20 @@ -734,7 +734,7 @@ static int vmbus_channel_notify_guest(VMBusChannel *cha= n) unsigned long *int_map, mask; unsigned idx; hwaddr addr =3D chan->vmbus->int_page_gpa; - hwaddr len =3D TARGET_PAGE_SIZE / 2, dirty =3D 0; + hwaddr len =3D qemu_target_page_size() / 2, dirty =3D 0; =20 trace_vmbus_channel_notify_guest(chan->id); =20 @@ -743,7 +743,7 @@ static int vmbus_channel_notify_guest(VMBusChannel *cha= n) } =20 int_map =3D cpu_physical_memory_map(addr, &len, 1); - if (len !=3D TARGET_PAGE_SIZE / 2) { + if (len !=3D qemu_target_page_size() / 2) { res =3D -ENXIO; goto unmap; } @@ -1038,14 +1038,14 @@ static int sgl_from_gpa_ranges(QEMUSGList *sgl, VMB= usDevice *dev, } len -=3D sizeof(range); =20 - if (range.byte_offset & TARGET_PAGE_MASK) { + if (range.byte_offset & qemu_target_page_mask()) { goto eio; } =20 for (; range.byte_count; range.byte_offset =3D 0) { uint64_t paddr; uint32_t plen =3D MIN(range.byte_count, - TARGET_PAGE_SIZE - range.byte_offset); + qemu_target_page_size() - range.byte_offse= t); =20 if (len < sizeof(uint64_t)) { goto eio; @@ -1055,7 +1055,7 @@ static int sgl_from_gpa_ranges(QEMUSGList *sgl, VMBus= Device *dev, goto err; } len -=3D sizeof(uint64_t); - paddr <<=3D TARGET_PAGE_BITS; + paddr <<=3D qemu_target_page_bits(); paddr |=3D range.byte_offset; range.byte_count -=3D plen; =20 @@ -1804,7 +1804,7 @@ static void handle_gpadl_header(VMBus *vmbus, vmbus_m= essage_gpadl_header *msg, * anything else and simplify things greatly. */ if (msg->rangecount !=3D 1 || msg->range[0].byte_offset || - (msg->range[0].byte_count !=3D (num_gfns << TARGET_PAGE_BITS))) { + (msg->range[0].byte_count !=3D (num_gfns << qemu_target_page_bits(= )))) { return; } =20 @@ -2240,10 +2240,10 @@ static void vmbus_signal_event(EventNotifier *e) return; } =20 - addr =3D vmbus->int_page_gpa + TARGET_PAGE_SIZE / 2; - len =3D TARGET_PAGE_SIZE / 2; + addr =3D vmbus->int_page_gpa + qemu_target_page_size() / 2; + len =3D qemu_target_page_size() / 2; int_map =3D cpu_physical_memory_map(addr, &len, 1); - if (len !=3D TARGET_PAGE_SIZE / 2) { + if (len !=3D qemu_target_page_size() / 2) { goto unmap; } =20 diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index f4aa0a5ada9..c855fdcf04c 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -1,6 +1,6 @@ specific_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c')) specific_ss.add(when: 'CONFIG_HYPERV_TESTDEV', if_true: files('hyperv_test= dev.c')) -specific_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c')) +system_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c')) specific_ss.add(when: 'CONFIG_SYNDBG', if_true: files('syndbg.c')) specific_ss.add(when: 'CONFIG_HV_BALLOON', if_true: files('hv-balloon.c', = 'hv-balloon-page_range_tree.c', 'hv-balloon-our_range_memslots.c')) system_ss.add(when: 'CONFIG_HV_BALLOON', if_false: files('hv-balloon-stub.= c')) --=20 2.39.5