From patchwork Tue Nov 14 14:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 743787 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2209552wrw; Tue, 14 Nov 2023 06:46:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVfx6qvdMG1oEwW9N3XIelli/qzOYNhXHtcXDFSM91dO8ypLaFC5vrxbOMeLrHasRYmlpn X-Received: by 2002:a05:600c:2d15:b0:404:6ed9:98d1 with SMTP id x21-20020a05600c2d1500b004046ed998d1mr7750808wmf.41.1699973175135; Tue, 14 Nov 2023 06:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699973175; cv=none; d=google.com; s=arc-20160816; b=eSG87/Pk8Mp8Mqchowsr+QkaL3RgLSqq0L6v94ojdZDBeYiCDFjjj1TBauH8VfGl0H yvcd/zKPwqY8Tcx+b80JQTYLCjhjFWby2+7j3vpbRoLJZFGlDFpR8xOYqutY2GyLNaON kjqoQkKkeEc7U5+5WVtPbHhGPTMtrKnW2jcb54aG8n5SM6+xnwNAQYFkpqv9WohWy534 oMSaujKTXs6zcGCAI5M/Ht5PTVcLaLejxJwsBK+UroO1anr3ScBIxemVssQWGDVu0wu/ JCWXepbJOfNJGYvn0qCufPAyJb0bnoEYapP9HF8KtSupAj9mJF/HC2fS4lOcg+f40tJT 4SGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=x5X2FluBMHtEHwLVURbcbmArZUeMN34wqMB+9uG3SGg=; fh=WgzlLWvbY5R8+4JotruerK0jeEkAYyt0q4wPP6dSEVI=; b=ElSxByyAIZe8YfxQKSCfXIildqlmSxy6xtbA7FOQOUz57DBsqRgy6s80RaBEt25B4E vzes1Hrh9w2sw1kP9I950kJsBXkEUujTJJxH2BIWlHVWxcDvkzdea+ED0jRioskas2f/ 9Ol29YRp6lHOxOBGSk6r00dpmUtPg2G634JV2T6645PKDc/U4mZzmBZUFcNo/Llrb06/ iEE09GPSjWY8PBq5X+pBQ7v8iZA6GWiwRjhHgA2uy7OungWgWyJkT5lN0Tx3CnSmaEdU AcksWjVvxxaKwXTRqxA3nksqGUSw60Aj+OYRFtWhJ8u8sWzQna0hz+o6IPJpiPHQA3UL Lqvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gSTJ8Rvi; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h8-20020adffd48000000b0032f7bf78581si4450689wrs.78.2023.11.14.06.46.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2023 06:46:15 -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=gSTJ8Rvi; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2uaP-0005Jm-RZ; Tue, 14 Nov 2023 09:40:20 -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 1r2ua1-0004k7-GE for qemu-devel@nongnu.org; Tue, 14 Nov 2023 09:39:56 -0500 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2uZz-0007yJ-LF for qemu-devel@nongnu.org; Tue, 14 Nov 2023 09:39:53 -0500 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507adc3381cso7602155e87.3 for ; Tue, 14 Nov 2023 06:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699972788; x=1700577588; 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=x5X2FluBMHtEHwLVURbcbmArZUeMN34wqMB+9uG3SGg=; b=gSTJ8Rvicj7iLETfyXC1+AX3u8+ZGZasmJlL75B5tcBGBcP+xw2ZbBkLSN6ak70pi1 hKU1Vgo7AjpBIhj4hxcGMQQnUUAJGfZAKgeN+SbDH572XVjU5osjXeOXKgRUCRZ9p+lk 728vne7r2Lg+VJrCqtodMYJ8EoKPDkl06w3OggPf0dEEPnWpXg7Cg0kO6P8U5HFXrfRS iz0ds24y6FmYo3j240BlKtHSMil71T6qboigv9WD5hIZI17x0ShJ/UrtxQVcYpmuNjqv Yds4ys3D/joJTzfXNMzyV4TBXDuCqHi+TvoFpqC/d/6h273kla5l7Ek9IfeNC9qbN3Wt Wa2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699972788; x=1700577588; 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=x5X2FluBMHtEHwLVURbcbmArZUeMN34wqMB+9uG3SGg=; b=vfIfFshe2wM8AkV3vG2g321qc7Qgu15CL6V8UZqU19H2qQkuK564ssAuQaAGbBFprt StGpw7LitrZpMYyQXx9iwdkt3GpLr7hwV2MDNKWC0f4YMjs03RoybtjmT2SgZHdl2RO4 jbl0JSTOy3QNYK2HJ2ptbR2HWcF3G04q5Wh5mzRobzsFz6aaWrj/rjCONayku/cn/WnC DM0nUJiM1GdNFjkL9iX+AZUD43Wg8XXshOjQ2xL8yLHZ6/upGy1HLQSYKN0gHZ/J/nV8 p2lgSksTv9N4CS5QUva5y+635asAc+aRCtwaaEUKfZ5ZUS5kXb6iFmi6mtS2UYZUOEGJ aahw== X-Gm-Message-State: AOJu0YzqZDOaqprcNpl9tBGkO5MGu0JEtPCOje4sFaMFixnPtvodY3u0 JavtgYe8Gf4FIcYqT6rVO3Ylxw== X-Received: by 2002:a05:6512:b14:b0:509:8e3d:7cb0 with SMTP id w20-20020a0565120b1400b005098e3d7cb0mr9400030lfu.41.1699972788532; Tue, 14 Nov 2023 06:39:48 -0800 (PST) Received: from m1x-phil.lan (cac94-h02-176-184-25-155.dsl.sta.abo.bbox.fr. [176.184.25.155]) by smtp.gmail.com with ESMTPSA id l18-20020a50d6d2000000b00542db304680sm5268842edj.63.2023.11.14.06.39.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Nov 2023 06:39:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: David Woodhouse , qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paul Durrant , qemu-arm@nongnu.org, Paolo Bonzini , David Woodhouse , Stefano Stabellini , Richard Henderson , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, Anthony Perard , kvm@vger.kernel.org, Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-9.0 v2 13/19] hw/xen: Remove use of 'target_ulong' in handle_ioreq() Date: Tue, 14 Nov 2023 15:38:09 +0100 Message-ID: <20231114143816.71079-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231114143816.71079-1-philmd@linaro.org> References: <20231114143816.71079-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=philmd@linaro.org; helo=mail-lf1-x12e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 Per commit f17068c1c7 ("xen-hvm: reorganize xen-hvm and move common function to xen-hvm-common"), handle_ioreq() is expected to be target-agnostic. However it uses 'target_ulong', which is a target specific definition. Per xen/include/public/hvm/ioreq.h header: struct ioreq { uint64_t addr; /* physical address */ uint64_t data; /* data (or paddr of data) */ uint32_t count; /* for rep prefixes */ uint32_t size; /* size in bytes */ uint32_t vp_eport; /* evtchn for notifications to/from device model */ uint16_t _pad0; uint8_t state:4; uint8_t data_is_ptr:1; /* if 1, data above is the guest paddr * of the real data to use. */ uint8_t dir:1; /* 1=read, 0=write */ uint8_t df:1; uint8_t _pad1:1; uint8_t type; /* I/O type */ }; typedef struct ioreq ioreq_t; If 'data' is not a pointer, it is a u64. - In PIO / VMWARE_PORT modes, only 32-bit are used. - In MMIO COPY mode, memory is accessed by chunks of 64-bit - In PCI_CONFIG mode, access is u8 or u16 or u32. - None of TIMEOFFSET / INVALIDATE use 'req'. - Fallback is only used in x86 for VMWARE_PORT. Masking the upper bits of 'data' to keep 'req->size' low bits is irrelevant of the target word size. Remove the word size check and always extract the relevant bits. Signed-off-by: Philippe Mathieu-Daudé --- hw/xen/xen-hvm-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index bb3cfb200c..fb81bd8fbc 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/bitops.h" #include "qapi/error.h" #include "trace.h" @@ -426,9 +427,8 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req) trace_handle_ioreq(req, req->type, req->dir, req->df, req->data_is_ptr, req->addr, req->data, req->count, req->size); - if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) && - (req->size < sizeof (target_ulong))) { - req->data &= ((target_ulong) 1 << (8 * req->size)) - 1; + if (!req->data_is_ptr && (req->dir == IOREQ_WRITE)) { + req->data = extract64(req->data, 0, BITS_PER_BYTE * req->size); } if (req->dir == IOREQ_WRITE)