From patchwork Fri Sep 27 21:50:37 2024 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: 831036 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp970322wrw; Fri, 27 Sep 2024 14:52:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU81J+zkYtcQZdZr5NkFq7mnprGMWD70KKUkQT85qLxNHowZzAbHitAqhmzbhC+QEh4szC5eQ==@linaro.org X-Google-Smtp-Source: AGHT+IEycv5FXZU8WV/V9TwJXksF47bt8za0Yz5/LvxfSrW5j7TLOyVEP4siHJOj3RhE05aNt1Mc X-Received: by 2002:ac8:5781:0:b0:45b:1d3:d9a8 with SMTP id d75a77b69052e-45c9f22d94fmr59879611cf.27.1727473943386; Fri, 27 Sep 2024 14:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473943; cv=none; d=google.com; s=arc-20240605; b=eoSEssBSCRyRSpHoDGH5aaOj5QrgXvkgvyaS0Mb8MbKsWVWnjAvpQTnx48yMYB6m2K PfYny8Pe1CmCwyWIHr4RNSSt7DdugU9mbI5tMIKlYa85rAUgOrTTahYcSg5PNycH+mWJ +b/VRRVkxlswQCzrhgYGrnmYMACWkBg8pWI5FPvSXSeTPtCifOGE8ZI1/d4ofMVBO1/W uhfmFHf9rh0NCVv/ixK9/+qzphRppXfstc0y0vHPym7f5hSgQbOZ4t6XiI73GaKNiEOP Eo/bccRjld32ws8BcPIF3go4InnmmoxXK6nhcDNByIEEbFrH/z8sQfVXAKKWo6HVSKdi ahMg== 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=Tq/WU8YFou4tlFTr5oZ2aHrtwQxQNFO3jd7/jY9s2dw=; fh=RmN1jlYmXsQbVTmV9F6qW9Y8GnhBM9smQ17UMdrtna4=; b=Xgf1acuB9o65Kz3fcacPakGEQlyXm8ayQFQ+BVL20K4i1ck4mPY9reKObudlVWpEDW uMVzhA7epK2ZaXFJt0ro93JDDGIsWD0X6Y+cczWkOSvHuY2pfwozpI72oBdNx5Sw7Cbk +p6uJ2ySdmBAFwmFtbCd0Tx5h85DEsHjIWz/tG5M58lg/cZW4wp7ybAl6kmR2M9uTaiY ghymxyHSCV3mEgCHJUGLNuGY9cfwCrHTPOlU3iTsdSdUS163n6vOqk6rhQz7lk9J+qBU weqA8Iy+HV4yBPFoXvWancVWyZZ5+qED9xJD+fL+4O5W+c7pIzM2CI/q8jMFoLTwMKzZ qGKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gO8VdGVw; 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 d75a77b69052e-45c9f328ff6si34485461cf.276.2024.09.27.14.52.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:52:23 -0700 (PDT) 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=gO8VdGVw; 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 1suIrZ-0008L5-Gn; Fri, 27 Sep 2024 17:50:57 -0400 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 1suIrW-00088w-7v for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:50:54 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suIrU-0004UU-Iq for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:50:53 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-37cc810ce73so1644250f8f.1 for ; Fri, 27 Sep 2024 14:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473850; x=1728078650; 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=Tq/WU8YFou4tlFTr5oZ2aHrtwQxQNFO3jd7/jY9s2dw=; b=gO8VdGVwugSaYnGG2iLdKLBJBxCENa8edM8l5Y8LsDmKhK5uTlJ23tdCyxDLZSei91 ji+9Ij1oTd936JniIXZUkNt/VnTjNHyDZ0s+RKCZeALF6ZndHbBz/fKXpfV7RUVoQ3pP qFQKukP5vJYe6TKsY/yWo/0uLxjlVUpQBAzwx/VPlsojrM2MH4dPCFigW/6pXIt9GC1l MrrFbirzDaOw+0yeFQ/gLIxruV8cU1nrnZ+GtosL6cbYx54QuZP88LUfp9suR9cNT0dY UKvz4XmxANGgV6R4a5ZWCbODL8FC556YcpklrNlYXyelwlBMGCDzNxIAS9bBFap7RiJp 6Hvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473850; x=1728078650; 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=Tq/WU8YFou4tlFTr5oZ2aHrtwQxQNFO3jd7/jY9s2dw=; b=SOMFpWVwmmTNDOMjmtj4cx7TINP84UOvuE88O1FTQLo57K+OUex+ZqxVjzxh3ABENQ YTV7nT+P0J2ZIFAQJojrM2obq9lTEB+3N8hdj7ypnQ1Q29pZT8Tk8yJTJE0XohlwyDhV 8lRfKPV6nLYUFhPAN66Rb6cCiM1zHzlWK7C0YwMLw0OsV7IrerOf5NxnoHIWCgNGNNDC 3M8Eq13f5Bn4picG+7V2pjeZzxU2VZrIlnxuFbrk6zegsdi5L+imSdsoDSdYEfXrKyfE XAdb5LmTuAnC+k5tt1MHaJyHxEZCUspIRsYCKA4AKwMvl9rmZ74CBuip84oSHJL8/drb 481g== X-Gm-Message-State: AOJu0YwzUY7et29pvJilHWYKj1/fN+vmAPzM3J50gFkwi06pXxFEkRu1 f6fzAepn5agHNe0g4jgFQb1wcldVOSbHG38cA97b9w7F1KJByMo4hstYU8tPGpGn4Se6Z4/dIR6 o X-Received: by 2002:a05:6000:bd0:b0:36b:bb84:33e2 with SMTP id ffacd0b85a97d-37cd5b1255cmr2402385f8f.37.1727473850434; Fri, 27 Sep 2024 14:50:50 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd5730e92sm3386868f8f.80.2024.09.27.14.50.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:50:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Jason Wang , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 1/4] hw/ppc/spapr_nvdimm: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:50:37 +0200 Message-ID: <20240927215040.20552-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927215040.20552-1-philmd@linaro.org> References: <20240927215040.20552-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 ldn/stn methods handle the access size, no need for the switch case. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/ppc/spapr_nvdimm.c | 47 ++++--------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 7d2dfe5e3d..5af0b13370 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -250,7 +250,6 @@ static target_ulong h_scm_read_metadata(PowerPCCPU *cpu, SpaprDrc *drc = spapr_drc_by_index(drc_index); NVDIMMDevice *nvdimm; NVDIMMClass *ddc; - uint64_t data = 0; uint8_t buf[8] = { 0 }; if (!drc || !drc->dev || @@ -272,24 +271,7 @@ static target_ulong h_scm_read_metadata(PowerPCCPU *cpu, ddc = NVDIMM_GET_CLASS(nvdimm); ddc->read_label_data(nvdimm, buf, len, offset); - switch (len) { - case 1: - data = ldub_p(buf); - break; - case 2: - data = lduw_be_p(buf); - break; - case 4: - data = ldl_be_p(buf); - break; - case 8: - data = ldq_be_p(buf); - break; - default: - g_assert_not_reached(); - } - - args[0] = data; + args[0] = ldn_be_p(buf, len); return H_SUCCESS; } @@ -325,31 +307,10 @@ static target_ulong h_scm_write_metadata(PowerPCCPU *cpu, return H_P2; } - switch (len) { - case 1: - if (data & 0xffffffffffffff00) { - return H_P2; - } - stb_p(buf, data); - break; - case 2: - if (data & 0xffffffffffff0000) { - return H_P2; - } - stw_be_p(buf, data); - break; - case 4: - if (data & 0xffffffff00000000) { - return H_P2; - } - stl_be_p(buf, data); - break; - case 8: - stq_be_p(buf, data); - break; - default: - g_assert_not_reached(); + if (len < 8 && extract64(data, 8 * len, 64 - 8 * len)) { + return H_P2; } + stn_be_p(buf, data, len); ddc = NVDIMM_GET_CLASS(nvdimm); ddc->write_label_data(nvdimm, buf, len, offset); From patchwork Fri Sep 27 21:50:38 2024 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: 831035 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp970037wrw; Fri, 27 Sep 2024 14:51:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSE4qa8pWT3PZa2lUhq2sQfBqkM05wRuOWzxV2zMGS/LFRhl0ewISLqqcro53GYgs0fV3ZUw==@linaro.org X-Google-Smtp-Source: AGHT+IFz8Zpt8td8shiEm1vD7XcOBsvNk9mPXeUbPGqY8jUf7y9p7Rd8qKaCUJpEmC7j/kAr4tle X-Received: by 2002:a0c:f408:0:b0:6b5:e2d9:cfb9 with SMTP id 6a1803df08f44-6cb3b63f633mr66502416d6.39.1727473878440; Fri, 27 Sep 2024 14:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473878; cv=none; d=google.com; s=arc-20240605; b=UDZaSahFTLdKp6ZQ2QvMO2ALqCETOtVa/F9UmFH13zMOtD+9ndwIe6rd/3p6Hi5rD6 BWb5X2E7YA6my5CKW8sqqjdDlNVBhSuQcEtrB38yBx9faQMsO3HlbwDBJSKZkc0FuJWD 1bkl23fDOE8u1f221k2Avx3ag3D4bQb7SOgVuo72DESUHMdYYa7K7hZOmuiH5IFVi5QB K44vue/osogxpQESVjBI09MdAmDuxM8enfEQW/Vq5bAcI8R/CuW/G0otzb59FyEtgbUm fCd5gVKObPHfB5pW96iEmSlyZfABH6c49huYO7mYRZlJZuHWeEJevqRpzunToej0Dj4G iN3w== 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=22wtNkwk6lzPh2EtQj85F8jLpnswm9ZtwKSArURcwyA=; fh=RmN1jlYmXsQbVTmV9F6qW9Y8GnhBM9smQ17UMdrtna4=; b=IR8YGSRHHxS1wfB6//jpi9YPTrYqha4RrisFazUyWpGhjVBThe0X2Py8CFmVbk8K/P IQCaZw3ja5o/t6izMsfS+ePXhGCuJ0NNMAfrWqcccWm094eJ11cSqjmpR7ufQ05v7E16 ei9frihGX65/w/hCM34eTFTFT9FklYvbJTDYWGeKmcEMUr81qi8PSwdNGpxwu33nw+ei RA+zWRLYctzkGrdRCKoyTttmjK3qzpElZQI5rPKUOKjpCY/oq1HdOCH5erbe8EU42zRD ouvDcJnyZ3dmmGr+ePZ/0q+Wo7zQp0cDREu7pdbdkQToMx1Pmra+jXTUAFRFI7GmGCHk x+xQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QkPRz+pL; 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 6a1803df08f44-6cb3b688569si31118706d6.330.2024.09.27.14.51.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:51:18 -0700 (PDT) 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=QkPRz+pL; 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 1suIrf-0000Ql-MU; Fri, 27 Sep 2024 17:51:03 -0400 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 1suIrd-0000HE-Qj for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:51:02 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suIrc-0004Vs-5l for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:51:01 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cb0f28bfbso21653065e9.1 for ; Fri, 27 Sep 2024 14:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473858; x=1728078658; 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=22wtNkwk6lzPh2EtQj85F8jLpnswm9ZtwKSArURcwyA=; b=QkPRz+pLdQLCCNe5nHr11o0PskxIzuY4EDdbERvaQYDHYbQVdeCMQI/DieiTDjkcmI yuNnDwzpRw3XpjoJ2psCF3wedv7NNYKUQYfanIFSOah1tEEvoOttj6wOqqIW7YbAsO8R u7qbowIJL1IOEzGOOyCvAl9hkkQ8J/vZ+SlKDiLnhXZxQkhXltKLyiwSWxw+IqvS8Y62 djdUSrZr5wtuVjn/aK+IkjBfA7Oijmzosb3s6XDI1uT77sxmDgtszAHXp0lFzUnfGmCR kbc/kp0uMXJz+52HZ+4p2v3cvEwC7m+nya64IpV/47kYrGlbFxPwazguh/Vzrk2PfbxG l6rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473858; x=1728078658; 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=22wtNkwk6lzPh2EtQj85F8jLpnswm9ZtwKSArURcwyA=; b=BVz07ZlZdIZ7EQizuzxa9xoEXYEQDh4Bse6N/+OsnablZH1dvB9rnk81BeMZf5A2Qb 4uG7giuguMLarVPxeOxeCPZpC3QjVMfxQZnjfcxgHV/JqiAmk3yUoZNEd+XATLIqfakp PebZArw5HSUNonzAudUDNN414iKJTVJDz+15wv/4WTKUB31neAe6hCZQJhXlvTqcy7xu 9hkybcmoFs4RQITnWti1hNETZ2OKPV+BFHGkNO2mlvt39B60qOed2uYa159eDGECnwlu pFagjcY8t3U6AzOqeNjofueNnjSufmYJsyhEmytDQ4A30so/68uDE03KOeEUsPsdiJA3 oStg== X-Gm-Message-State: AOJu0YyXgpcLXU21KOmWK0pUNYV5HVtqizFCeibMmBN1ZOlv4txQJjjJ +hReW5eYgOAVV4mvhjCPWzZCpxAlG9cZ5fpPAdKgsn5D9SjhIYIF3IfnvTfjhWfOxEKB9qxzJE7 f X-Received: by 2002:a5d:6802:0:b0:374:c040:b00e with SMTP id ffacd0b85a97d-37cd5ae3362mr2642552f8f.39.1727473857983; Fri, 27 Sep 2024 14:50:57 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd564d2d2sm3476685f8f.1.2024.09.27.14.50.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:50:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Jason Wang , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 2/4] hw/ppc/spapr_vof: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:50:38 +0200 Message-ID: <20240927215040.20552-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927215040.20552-1-philmd@linaro.org> References: <20240927215040.20552-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 Directly call ldn_be_p once instead of ldl_be_p / ldq_be_p. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/ppc/spapr_vof.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr_vof.c b/hw/ppc/spapr_vof.c index c02eaacfed..d238a44d88 100644 --- a/hw/ppc/spapr_vof.c +++ b/hw/ppc/spapr_vof.c @@ -136,26 +136,17 @@ bool spapr_vof_setprop(MachineState *ms, const char *path, const char *propname, vof->bootargs = g_strndup(val, vallen); return true; } - if (strcmp(propname, "linux,initrd-start") == 0) { - if (vallen == sizeof(uint32_t)) { - spapr->initrd_base = ldl_be_p(val); - return true; + switch (vallen) { + case 4: + case 8: + if (strcmp(propname, "linux,initrd-start") == 0) { + spapr->initrd_base = ldn_be_p(val, vallen); } - if (vallen == sizeof(uint64_t)) { - spapr->initrd_base = ldq_be_p(val); - return true; - } - return false; - } - if (strcmp(propname, "linux,initrd-end") == 0) { - if (vallen == sizeof(uint32_t)) { - spapr->initrd_size = ldl_be_p(val) - spapr->initrd_base; - return true; - } - if (vallen == sizeof(uint64_t)) { - spapr->initrd_size = ldq_be_p(val) - spapr->initrd_base; - return true; + if (strcmp(propname, "linux,initrd-end") == 0) { + spapr->initrd_size = ldn_be_p(val, vallen); } + return true; + default: return false; } } From patchwork Fri Sep 27 21:50:39 2024 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: 831038 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp970324wrw; Fri, 27 Sep 2024 14:52:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3ehPnGoA7277EQNhLsyeaqvIAi8CsEI8p6SIKSafck6GMt/jfZk7iZApQ6nbYjhkJmeDzbw==@linaro.org X-Google-Smtp-Source: AGHT+IHZCkr/9c9kWB5Bu16bDs/2AicVMtlUO8gjhy+8xNYDTG6O9wsKFumyrtbGahwuoVgk1p9U X-Received: by 2002:a05:620a:4047:b0:7a9:ac2d:5996 with SMTP id af79cd13be357-7ae37856349mr626051685a.35.1727473943486; Fri, 27 Sep 2024 14:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473943; cv=none; d=google.com; s=arc-20240605; b=Pi100hBvRb9gRicEZ7D9jAYrO7JWsimsJZOQwswZPn+apTzteTlmIdPaMLYJVdafG0 i1nxHnKmXeNOe+Xfv1tSva7dG1klpn5xLfYV4PWH8xtBusMjT+i/Pb0cJ6dXKzzCzgtc wEIl/zsvhizE5YWZNeY8dfm9Zqv3FcPpyPIdnigOoF+ZFHujzMcyFNEId+CKb1+Mk7j/ 0oYRf21iJifBxoK8X7OgPxYmFgxdg8XxqfYmfP25d1zOTqccQRrWuFzWCSM6eTS84G/g TXJ6pfUwJpGYB3pBum4EvDnMWPnGCkYw9MrdYZghLA9voY6UrR/xTMC1fHZU/dxRVPzw rKsQ== 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=ncMwuXMgt8w0SPLSq4FNQgB95v0Fxit0yyRMSKvDcb8=; fh=RmN1jlYmXsQbVTmV9F6qW9Y8GnhBM9smQ17UMdrtna4=; b=TcYDdcvrtJp2tHuEGE2A4sbkrpejhzGnIEp2GrSdPeSQby5tzhDI91x2HqFiGyND17 kaNudbtwMktxO2Kfy9ofL8P15LjTLjeWrTqm2RzPFo+mgzu2CEu4dXEN06GO/E9ahfcE PMXBu8CKPP/fCDoS0db1V0Flkyg7Q3t/vx+XUOxdmim7F3lVr0S0E5cEGabjzcxSSTVt GQwWiHqjUJ7+BZU3t5HKULDsEsQLOPIaOyx3kSQNzhBUvxgopZoYDWr3N59IG0DvQPqz eYJ1ngLN4LDTT9nCaNh2z3dDSZeQJmfMG/4y5Vz2mS31u7VNTjlDVdeDTzNxTsG1nuhE JFSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=scF2UBII; 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-7ae377cff62si320960485a.55.2024.09.27.14.52.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:52:23 -0700 (PDT) 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=scF2UBII; 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 1suIrv-0001Ye-Ar; Fri, 27 Sep 2024 17:51:19 -0400 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 1suIrm-0000vG-Tr for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:51:14 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suIrk-0004Wk-BL for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:51:09 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-37cdb6ebc1cso557105f8f.1 for ; Fri, 27 Sep 2024 14:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473865; x=1728078665; 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=ncMwuXMgt8w0SPLSq4FNQgB95v0Fxit0yyRMSKvDcb8=; b=scF2UBIIBiYiLDbYDnsB3QYay6mBwhBxAgIghWKzonYoLiGLKitRMA8Oi9rm7OkZau StavgAwciko8YWhNNPF4zLopqce67vrrXmAsZQmPVEfh6tuobs/DEY2lB4ahCaGoODG5 3EoqZINZAfL8MrXZ7hr72/e0tE5u3yzMVqw8XXndflzsTVVPCNyxhC3+H8A+sP4V+Wrt GCEmM0aQwOvxyXiqPkCL9LgZB6G93g+ldLCPNcV1046Qy7CUh9SpA7G9dOVkiTCUQvU9 bR5ekydBwGTOKEoYSxKE0gPfkCIWI8anFXPf3ccZruY7MspXJLdBnK1lkST9XlyZdr+B E1pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473865; x=1728078665; 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=ncMwuXMgt8w0SPLSq4FNQgB95v0Fxit0yyRMSKvDcb8=; b=eLZ9UiJW6ePYEDuUuqsC8iV+7OY3pNmjlsIjMaKZCrM5OdZGauqNdOoj1/YI3jJ0j5 Hiar4iWnVrJNps3RXBKw65qcgSKqXBNoyOxoQjaUO5UAqQVl4ZyNgn+LC10EcRoSzf7T DlH+8rYsnpDZH5s6Vo57BPQ2OK1K4HTpcTdYaUZ1K6JAADwnVPTnLaWnbf4iIKtV37L1 yehzYGms/8VwQd1uAaQD52Te3eMCKraFyUHi0nxCs37+ceKfoSLLtRebOZpO6z27cJ/X A2f8E74rOpEQNOnF24UChsPzf+zolE/1g35LDNHy6WZ0+Y4ak3mjAbNVI9Fw65Far9X8 MQog== X-Gm-Message-State: AOJu0YwB5lDF+w8PVweCO6l482qufhBcLUqYK4gjiMYf1W5frOaSnJ5b loh/3FUMZkrlEFzVYe2jaWZJnnbliaQWKmAaFBYo4u7hZSyp0c7/w6+3/TiB8lCNkGiv7hByQ8B + X-Received: by 2002:a05:6000:52:b0:37c:d244:bdb1 with SMTP id ffacd0b85a97d-37cd5ad83c8mr2643155f8f.26.1727473865525; Fri, 27 Sep 2024 14:51:05 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd565dd86sm3420517f8f.27.2024.09.27.14.51.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:51:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Jason Wang , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 3/4] hw/ppc/vof: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:50:39 +0200 Message-ID: <20240927215040.20552-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927215040.20552-1-philmd@linaro.org> References: <20240927215040.20552-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 Instead of be32_to_cpu (equivalent of ldl_be_p) and ldq_be_p, use ldn_be_p(). Similarly instead of cpu_to_be32 (equiv. stl_be_p) and cpu_to_be64 (equiv. stq_be_p), use stn_be_p(). Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/vof.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c index b5b6514d79..e2549ab786 100644 --- a/hw/ppc/vof.c +++ b/hw/ppc/vof.c @@ -628,6 +628,7 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base) const uint8_t *mem0_reg; g_autofree uint8_t *avail = NULL; uint8_t *availcur; + size_t elsz; if (!fdt || !claimed) { return; @@ -645,11 +646,8 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base) mem0_reg = fdt_getprop(fdt, offset, "reg", &proplen); g_assert(mem0_reg && proplen == sizeof(uint32_t) * (ac + sc)); - if (sc == 2) { - mem0_end = ldq_be_p(mem0_reg + sizeof(uint32_t) * ac); - } else { - mem0_end = be32_to_cpu(*(uint32_t *)(mem0_reg + sizeof(uint32_t) * ac)); - } + elsz = sc * sizeof(uint32_t); + mem0_end = ldn_be_p(mem0_reg + sizeof(uint32_t) * ac, elsz); g_array_sort(claimed, of_claimed_compare_func); vof_claimed_dump(claimed); @@ -674,18 +672,12 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base) size = mem0_end - start; } - if (ac == 2) { - *(uint64_t *) availcur = cpu_to_be64(start); - } else { - *(uint32_t *) availcur = cpu_to_be32(start); - } - availcur += sizeof(uint32_t) * ac; - if (sc == 2) { - *(uint64_t *) availcur = cpu_to_be64(size); - } else { - *(uint32_t *) availcur = cpu_to_be32(size); - } - availcur += sizeof(uint32_t) * sc; + elsz = ac * sizeof(uint32_t); + stn_be_p(&availcur, elsz, start); + availcur += elsz; + elsz = sc * sizeof(uint32_t); + stn_be_p(&availcur, elsz, size); + availcur += elsz; if (size) { trace_vof_avail(c.start + c.size, c.start + c.size + size, size); From patchwork Fri Sep 27 21:50:40 2024 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: 831037 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp970323wrw; Fri, 27 Sep 2024 14:52:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2pYJKsLFrQSWUl0k3UqB12KaPkd9qV33upKknv3kEVaj9t1iZkUugBM0p+yiocumoTGiZjg==@linaro.org X-Google-Smtp-Source: AGHT+IF8UdBaca+uP0fEMbPIKM+p719ZSB6I28B1l7+TFRRPEBw4ZINj26Gl8wcT99N31Mv8lHYg X-Received: by 2002:a05:6214:4385:b0:6cb:394f:16fa with SMTP id 6a1803df08f44-6cb3b5e4e93mr47011346d6.4.1727473943374; Fri, 27 Sep 2024 14:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727473943; cv=none; d=google.com; s=arc-20240605; b=UG+lxQBb51QbQHy7RAMhSWPTar0RgmsizbGjxm2kETjvnTnYNziffcRPy2lAysmfaS 7UX0KNK19v0rt20DaVHWcEMmvInAPjCWiIi6u+TKXppJqp2BNHtcKyfPHITGBx8LGFmh 5X2mDgrDYrZL4j4G7NF+C/DXug5p096UWkoowE+GYrc3SE/3rzXb6p38jRvnWYCG+hoE qS2wJT/ngf67s1dcmYHiGGdHR5iIQpFGEbQnknf6IdmqTJUvIYughbqTLZDsivBid40e uyinIaFi7dmoOfgQch3Cw05UDcmLKg0T7dYq+DOXgcWWqjhyJXUAed4wRMSgV49zcPV/ woTA== 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=e1vHxexCTLbdRB8r0KvJgoIHaBve1hvZ62MNg9aoNm0=; fh=RmN1jlYmXsQbVTmV9F6qW9Y8GnhBM9smQ17UMdrtna4=; b=J7i1/emL92dxqIvxavVa4CNGGw6mfzhCg1sPAY1P/hlsszsPMqfu/CKcGVY68sUKAF QSRDX93kejHyOI59iNK/eVOjZRILOiptxed1SpkKZu1wziQDtDK02uuTWMMHo2rtOOU9 rGxTJsrndUlcjssgB/m22wA4CeKRTKoLaWOY5+qWfX9OdH5YRTPNyjkqtcYgGLl+CwBB PD1u/JDR96YpnjckxLUz5BR+sqSs2XkxyiPMOvBqKOIK3BMBQz1zF8+1zm4cEAlIL5Y6 mUCylgfeZ6YteulsJcxI4TX3++lL5KMo/w/oGKvEItP+nsjIluUPUAoksNcNksYlyACv Rygw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oBMIBkWw; 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 6a1803df08f44-6cb3b6040cesi31682046d6.92.2024.09.27.14.52.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Sep 2024 14:52:23 -0700 (PDT) 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=oBMIBkWw; 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 1suIrx-0001h6-3j; Fri, 27 Sep 2024 17:51:21 -0400 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 1suIrq-0001CH-Ur for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:51:15 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suIrp-0004XQ-Jj for qemu-devel@nongnu.org; Fri, 27 Sep 2024 17:51:14 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5398996acbeso1320321e87.1 for ; Fri, 27 Sep 2024 14:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727473871; x=1728078671; 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=e1vHxexCTLbdRB8r0KvJgoIHaBve1hvZ62MNg9aoNm0=; b=oBMIBkWw4/mAGSdEwQB+XCf5Ee2YWdXHuQ7fHkruq7pyb7qBrudcCXSdoCwEOGBC0g HA+t1waJj8/pRKEdP/mSSz38+dK+Pt19z4XBFpNERQdiZRGohl+zvYb92QWY+Xb6QReQ p3+fGQ5QhSn+99vQHULFdCxxvF4vBeG6HzdjR8DT3d8X2kAyAhAJ26jdH3FYCr+CnIVB rsaNMQTjogCULAVUtRr7KGh5oCa+5Feq7EshjVwRTwpXz5D2giDwyRDBkIMt2CoAgkum Wnygvd9diFfpiJCPJkHalxOs+X+drIeDw15+D4wkIUMlz+pFomtgCJ3WtS49XNslcEBt ae3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727473871; x=1728078671; 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=e1vHxexCTLbdRB8r0KvJgoIHaBve1hvZ62MNg9aoNm0=; b=ZikVl3BM6qkedCCcz/yf3AMYhjuEhzgwaGVgS+Ya0OUm4FyIi3PxD5vwLkRlvaZ7uu eaTYkgoMjDkoIYYNszNcuPpTaexGfFzztJYQkINyk9zc6azT5dsK3oFsEdhXQ5/0OFZ8 Z5LLMOPXaOoeTYZorAPy5lQ/eftlTo5Gh0gFeoGf27PL9BrjRW61rqzwMeivSxJ1FAf1 tnENnNfzE6mROwxl/dT4cMSquENWHP1Riip9vR55YTZ/uD6bJr6jJy7GtA+paQy1eNuf r1rWPHYHfl732bFQVosiidZ+dOlvEM3+h/bRzV0H2VXiAWWaTvnyCNV4+BzMvAzBqPMv MLVQ== X-Gm-Message-State: AOJu0Yy4M2Jv0JJtTEPUDKItMexrZvGrxx3Ut1ihZwRwjE6nWId139EK /mPbWWArwH+o65vJa5TKcIfS2U3bP+1x7QiARkg8fJYkmVjZXRBr08X6p+McYB1J0x36XQlEy/8 l X-Received: by 2002:a05:6512:1384:b0:533:4327:b4cc with SMTP id 2adb3069b0e04-5389fc810ecmr3283260e87.52.1727473871210; Fri, 27 Sep 2024 14:51:11 -0700 (PDT) Received: from localhost.localdomain ([176.187.217.136]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e90cd8c5asm111112965e9.1.2024.09.27.14.51.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Sep 2024 14:51:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Jason Wang , Nicholas Piggin , David Gibson , qemu-ppc@nongnu.org, Alexey Kardashevskiy , Harsh Prateek Bora , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 4/4] net/l2tpv3: Simplify LD/ST API uses Date: Fri, 27 Sep 2024 23:50:40 +0200 Message-ID: <20240927215040.20552-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927215040.20552-1-philmd@linaro.org> References: <20240927215040.20552-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 Directly call ldn_be_p once instead of ldl_be_p / ldq_be_p. Signed-off-by: Philippe Mathieu-Daudé --- net/l2tpv3.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/net/l2tpv3.c b/net/l2tpv3.c index b5547cb917..7a0d5dcfe9 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -318,11 +318,7 @@ static int l2tpv3_verify_header(NetL2TPV3State *s, uint8_t *buf) */ if (s->cookie) { - if (s->cookie_is_64) { - cookie = ldq_be_p(buf + s->cookie_offset); - } else { - cookie = ldl_be_p(buf + s->cookie_offset) & 0xffffffffULL; - } + cookie = ldn_be_p(buf + s->cookie_offset, s->cookie_is_64 ? 8 : 4); if (cookie != s->rx_cookie) { if (!s->header_mismatch) { error_report("unknown cookie id");