From patchwork Fri Mar 7 21:56:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 871271 Delivered-To: patch@linaro.org Received: by 2002:a5d:64c8:0:b0:38f:210b:807b with SMTP id f8csp980024wri; Fri, 7 Mar 2025 13:57:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWbz6lsVV0NSR+xh+PSkHmUZ7+yvxn1PPxh/J7ckouXIbSEGuuEEDAUV3JJpjGirUqYiN1tLw==@linaro.org X-Google-Smtp-Source: AGHT+IEGdmnVT8DAK+9OGVKYrBJSUygkpaHKLFXB/lcaOqyEe7qOYKdx+1X1uaFbnT4YKR8+66cz X-Received: by 2002:a05:620a:84c7:b0:7c3:bf23:132d with SMTP id af79cd13be357-7c4e60f05demr811490185a.19.1741384661028; Fri, 07 Mar 2025 13:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741384661; cv=none; d=google.com; s=arc-20240605; b=E9qT2nj1CebsvBDjDQ43BJtWMg4wHsC57s/pqiov+A9v0bWugseDDuXBvDINDYXpA8 LG24CPayX0JxViNQcaftnV4W0ozZgNpQuqUTGeJZo+ql6OM4zwvaUHtEEENtssVmipax Y6qzA4BTVEtrSyJhd6Z5sgvCNjkOHPWhlPgINT1hTRGT/nOo7DixD1Kn0Q5wc+uouRyJ DdwTRLzrIzBWqzG6rqiEPDrHbGyiZfoZ48HBZaTuQFa1UagurIzybfzpY1gddu3dpHwU 2o26MQZMmpXvGjH6rtAhYTG6xcpkQFDoBlcwtYSG0z+XCTHsR1eTx0DHmDO41EfSSFdF 7y0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TvAuOoN8/PzrW6ePLHQAaqYQcMX7nhU7k0OaOWGrsUU=; fh=hipmfhSGa4WVtYLLPcg94YgUb7EgmjQTwNEVz4+dVKk=; b=BSmc17ygPuM8z5lIffIhRr52yqirU6KjsdTjoH1TYlxg/20bWcd74lhqauhDE9obSm D/rx3hGJXc5QS/MxutxaLP00GoJqW+odcneFvRcQQ3gfBYZ4fr+blL86S4i+/QK6Psy9 uosRMCfG9oOi2NiN56N66rQLCW6ZSZdy1gKQliHWMVESH/UaF2p2ak8Fs22Zc7Bqan4M I9jYUc+k6K1iM25sMaGXunBX6gsXWpmovZZY6BEroMpZEK1VzWXoWvTPR5wlQKMiV0eI x1JGYP+Q+j6uaPxX/ykxxZDrF4zaeuOnm8OzFa1EUjYwPEyuBYMv0iwOKOeFJUqmgqLV 9frg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YnCdP0j3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c3e5547716si420381285a.552.2025.03.07.13.57.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Mar 2025 13:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YnCdP0j3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqfgR-00050Z-PA; Fri, 07 Mar 2025 16:56:43 -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 ) id 1tqfgP-0004zh-QF for qemu-devel@nongnu.org; Fri, 07 Mar 2025 16:56:41 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqfgN-0001k2-P7 for qemu-devel@nongnu.org; Fri, 07 Mar 2025 16:56:41 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-22337bc9ac3so49803275ad.1 for ; Fri, 07 Mar 2025 13:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741384598; x=1741989398; 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=TvAuOoN8/PzrW6ePLHQAaqYQcMX7nhU7k0OaOWGrsUU=; b=YnCdP0j3ITJ+3zMAyl7Xq71hQgRZyF2Vy3UuTvMYuzMT/TiiQ6jYqw2BHzISDGdIfI 9pC3Qm6II+BEf5REWkhB7MkgdXQP5jao4yFymAGjtCFqftcv95fZcKftIMZaZibLieLe zXkmGFlehVGNiXcbcY+321pKVDGPiQ6xXza8ZjaPEF22vaTdmZNhf2qoQ9HFNrji6CjB RZ8Eo6+UWaZ+m1EugDJWJ4pCGb6DDLSOeTyOmcXocmXcOgBWi38v4fcY+kBSEmIsDI7J s/wefnzROfB+kZ1I6w24R7aWVnp7SRI4TZUd1UV9NW4GlVtOKv3TlZyCK9ieo497Kj7T csWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741384598; x=1741989398; 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=TvAuOoN8/PzrW6ePLHQAaqYQcMX7nhU7k0OaOWGrsUU=; b=i9q1ALrgITodDhArvz3gdgcAEUuMha5l0D3Q/0bcRHUnlBWWzmA2I41IrWLdo/2c+y 9efGNFxZ5vfZbQ00fikWgzPbd68CaBHwGJThrRIjRgXhUCDmWwZvKNqRptzhFru4nVCM LjJV5xUTfmH5eVAyBQvq0xStlrC8mGWMOD3YA3c7gaY5me+AoMgnlQL/5c/ogsM1N0g+ bJe3OKF7gNEL8PSM4c3MW3eHkMUMPWkBd9hnnYdHrqV0Su6dLVGeXMVAif4uQQnBpT+9 W1srmsa+gzqb5iWxF9evd8Bbyi5u8kItA6coX9gd1I/i2ZshbsR9PPBHm/cFqtTD/07x E07w== X-Gm-Message-State: AOJu0YweJoKdWI1oDwbKsijVMr4E+78IPCzJo77vHTmEdjHjmGWlNKx9 orWyLIpU3EzVCPamf0+i7qhXma4gZtjnlaiU0npz7eNpVyEGLYUh6acLNzgUrmKbyiQpVEH1H87 a X-Gm-Gg: ASbGncs23UTPQy+S5iOMuiQyweYRI6gR1wc7rgvrcl7EbyW7u1v45KT3FlFIv3t7DpO HoHoQkJgS+t/g4oVsl86BN9VPaoQLrPc4dvz9YOxGr6TCmvrMkXJjM87XhdfbuR/GScVyHHB75w NHWmuxJ2JbG3G1b+MaAXJ2tejyGD0vwrFgUe1T3364wMxPzJnPe+HNsGukeCQsTMcrmzHsmEZGP JGeKCAaAQ+gXnM20UJtZYr25rYYb4vH0Xehghb7DDg6oP7+aqkMUcIgUJ87mrss+JvBaKCOySaN sT3nt5kLfRZi6VMAh2mYVBqmVBDCjbZ9kKFW6wjCde0n X-Received: by 2002:a05:6a00:228c:b0:736:8c0f:774f with SMTP id d2e1a72fcca58-736aab02cd8mr7557373b3a.22.1741384598341; Fri, 07 Mar 2025 13:56:38 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-736ac9247dcsm2000927b3a.125.2025.03.07.13.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 13:56:37 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Paolo Bonzini , pierrick.bouvier@linaro.org, kvm@vger.kernel.org, alex.bennee@linaro.org, Marcelo Tosatti , "Maciej S. Szmigiero" , richard.henderson@linaro.org, manos.pitsidianakis@linaro.org Subject: [PATCH v4 5/7] hw/hyperv/syndbg: common compilation unit Date: Fri, 7 Mar 2025 13:56:21 -0800 Message-Id: <20250307215623.524987-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250307215623.524987-1-pierrick.bouvier@linaro.org> References: <20250307215623.524987-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace TARGET_PAGE.* by runtime calls We assume that page size is 4KB only, to dimension buffer size for receiving message. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Pierrick Bouvier --- hw/hyperv/syndbg.c | 11 ++++++++--- hw/hyperv/meson.build | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/hyperv/syndbg.c b/hw/hyperv/syndbg.c index d3e39170772..948829e6d89 100644 --- a/hw/hyperv/syndbg.c +++ b/hw/hyperv/syndbg.c @@ -10,11 +10,12 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h" +#include "qemu/units.h" #include "qapi/error.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/loader.h" -#include "cpu.h" +#include "exec/target_page.h" #include "hw/hyperv/hyperv.h" #include "hw/hyperv/vmbus-bridge.h" #include "hw/hyperv/hyperv-proto.h" @@ -183,12 +184,14 @@ static bool create_udp_pkt(HvSynDbg *syndbg, void *pkt, uint32_t pkt_len, return true; } +#define MSG_BUFSZ (4 * KiB) + static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa, uint32_t count, bool is_raw, uint32_t options, uint64_t timeout, uint32_t *retrieved_count) { uint16_t ret; - uint8_t data_buf[TARGET_PAGE_SIZE - UDP_PKT_HEADER_SIZE]; + uint8_t data_buf[MSG_BUFSZ]; hwaddr out_len; void *out_data; ssize_t recv_byte_count; @@ -201,7 +204,7 @@ static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa, recv_byte_count = 0; } else { recv_byte_count = recv(syndbg->socket, data_buf, - MIN(sizeof(data_buf), count), MSG_WAITALL); + MIN(MSG_BUFSZ, count), MSG_WAITALL); if (recv_byte_count == -1) { return HV_STATUS_INVALID_PARAMETER; } @@ -374,6 +377,8 @@ static const Property hv_syndbg_properties[] = { static void hv_syndbg_class_init(ObjectClass *klass, void *data) { + g_assert(MSG_BUFSZ >= qemu_target_page_size()); + DeviceClass *dc = DEVICE_CLASS(klass); device_class_set_props(dc, hv_syndbg_properties); diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index c855fdcf04c..a9f2045a9af 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_testdev.c')) system_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c')) -specific_ss.add(when: 'CONFIG_SYNDBG', if_true: files('syndbg.c')) +system_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'))