From patchwork Wed Dec 18 18:21:02 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: 851756 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1078269wrq; Wed, 18 Dec 2024 10:22:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVMDVehkzcwzaiMoOR8+d4WVigNRgSRd9HkMoniunTO/H/Ehm7BhSTqaL4zIDp0sL3BDyx/5Q==@linaro.org X-Google-Smtp-Source: AGHT+IEK8IY3B/WbYWZ7hW+1ezoH6bRJ06Nt9mSUmsM5NQCOx8dDalU25vZvXLThZcerhegpIzzB X-Received: by 2002:a05:6214:4b03:b0:6d8:aea3:e27 with SMTP id 6a1803df08f44-6dd14c97aa2mr11160866d6.44.1734546173443; Wed, 18 Dec 2024 10:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734546173; cv=none; d=google.com; s=arc-20240605; b=ZnZ5+XdnB4+hd3md+YjRS1LpxuaujPqhdDjAfq9BlAu5GBTp+8rw4CGC+ROVXXxZW1 IvhLUr3yCLX6/c2wTg2ljFDBQcVtYu2PQ9IGx/jusitHiCb3kZMgUcWUaQ9LJcb46JE6 fIcEZffc9H3xNnQeOMpjiUHaVfxsDc7ya341Qab/LUi2usS6CSznXzesBXhtv1y7MleL vAQ6DzVtKWy5HztEmdZUtoKYItWZEyyTP9YqtrgOONjtuexRWfi8DOwPPXBEuDLqOyCi gTqo+pGx6fIrHK2emM8Kko8yMH4rTmNhPYAlltA8IW8AweMNDwo5/QVS/JJj2d35dtop VcoA== 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=O5jlRNCwvAALfsOlYNnOtkyFgySWMX0tusYOjYmCCCw=; fh=aDK3AYW/tYhipRsN4fimbcHK1l9GCjVTlWyiAdYPq8A=; b=X3KgWbF7Vnr6AZTfs/m9JFnIBo2bGnBr9f3jySXpLTy0XlBpw2KPjdT9bwEbZOPBAc dlw84g6kyWz459Ck2jySf/99RqJbJJnvE1P62K/b1d8b2cE6apBZSgZA8utQl2JteLIP 0l/adJIHWzHNoEIX586Q99j2pypKBmL9lKPuintBUEP0RruwUBM2hYbpmPNzYxU1zqAF BQegEgly8am5yBREJAfl6115R3ryom6Zq1JpFgH1M0/a4HhvsZmJQxiUER084XyeCqtl 3vDwOQf6NSqe7yaVHcsBD8D7lgkGgIe3CKmuOlumGTQqhju7OV7A/bxfbY1PkqwJrGoh gCcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mz1hhEWe; 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-6dccd3b7fedsi133223166d6.528.2024.12.18.10.22.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Dec 2024 10:22:53 -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=mz1hhEWe; 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 1tNyfn-0000Bo-Mg; Wed, 18 Dec 2024 13:21:27 -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 1tNyfm-0000BH-9k for qemu-devel@nongnu.org; Wed, 18 Dec 2024 13:21:26 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNyfk-0001mF-Qe for qemu-devel@nongnu.org; Wed, 18 Dec 2024 13:21:26 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4363ae65100so45282595e9.0 for ; Wed, 18 Dec 2024 10:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734546083; x=1735150883; 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=O5jlRNCwvAALfsOlYNnOtkyFgySWMX0tusYOjYmCCCw=; b=mz1hhEWepn1UPaXIdlP/XwfiHzK0xu2LRs34VJg8nxEog9JIckjBNHk+suenW+DEvU 0hqBjG5/rhwQZ7K9ucw4c0j4/sW+YVdrZzDX2JkrKM5tem+8zFvB6oUiQdIUFtOi4Vt7 WOVZpSzvt5YZLx/tWauD/w9AvWDPULqEKU7TfWO588EMAz2wXaKwgsQg/UKoFzv42S6f x7roVjvBpPkGWix5vpcxkRkDnYz7KeIMBfpMBnfsiZqDrMM+mLf2IaPsoRfqTviG/I1K t8fqHnpbbeeOnvNwZc5W4XWAUhwjFF+BJ03kFU0xh1+4Ai0vKRYSNd/s/aZzL7/nIeuG YlzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734546083; x=1735150883; 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=O5jlRNCwvAALfsOlYNnOtkyFgySWMX0tusYOjYmCCCw=; b=LgQhm9LYOkM5Lq1QH10/z2p5Tt3xWYfNhzViDqZQbeaBQ/3E6rnSaGfAS+FuGfLoIy OAT9ujDc96ZtCWKS1+pDUklI9WYuP0um7APht8P2L38WsGdlv9UzBJUjijFjR60dQBu3 1jWZD1QMsmJ8che33kukIUOhfFj9Lycb7iO19Mra2sL15zuacJmuU/nHA9vdm653qNBL g7yxoMVq22fxtiZB2lJypdr8+Bz2ja4wozaXODiAlQGNc/A7F0XIC/4zJ2nMBpavuD/w WmU4tCFehC8Smkn3/aSViIVQDIqWRxmYhwQXRsZgrFMPXtZ++KodOSuMO2/hv0FvyjyA Z1Zw== X-Gm-Message-State: AOJu0YwXLcUyoOAsLqKAA1IRfluZyQPIBYVVuix6Fxa6PgzOdbIKGXFN OAMrJunf3xMRjLsUbG4ymMrO+zG/GpN74pcWkJ5sCS3ej8SS9kd086Scf7zT5Pa4f3Py5L7zERo T X-Gm-Gg: ASbGncsPdo5VfRB1RES2pdTo6JoM+uoyvGHBJZmPTxRxUQsUEbXR9NkJLjXdyjBEzp/ 56v5tI/itz5WWXyaNXNf1t7PBAPshQGWVh800KwnSbBB4fGiLANAQynoJ6jfpxR8OgXm+XbcWFq uc7kVD5P3hpOgm/+sVXS/ZDFnbdu2na7bud6R+0tkU8uvTyg2DnHuv4r4rll/E615CsxBtYociL aQRnhP/xRGWFKMgf3RL62DqNXs5McO+s9u8TdYy2bdPnVdWIYX13YNjqsVHWl8Mr06DX6XOgd/r nVpv X-Received: by 2002:a5d:584a:0:b0:385:f062:c2d4 with SMTP id ffacd0b85a97d-38a19b34bfbmr656937f8f.37.1734546083045; Wed, 18 Dec 2024 10:21:23 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c806086dsm14570843f8f.91.2024.12.18.10.21.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 10:21:22 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Harsh Prateek Bora , Nicholas Piggin , Daniel Henrique Barboza , "Edgar E. Iglesias" , =?utf-8?q?Daniel_P=2E_Berra?= =?utf-8?q?ng=C3=A9?= , BALATON Zoltan , qemu-ppc@nongnu.org, =?utf-8?q?Marc-An?= =?utf-8?q?dr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v3 3/7] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method Date: Wed, 18 Dec 2024 19:21:02 +0100 Message-ID: <20241218182106.78800-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241218182106.78800-1-philmd@linaro.org> References: <20241218182106.78800-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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=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 Convert HPTE_VALID() macro as hpte_is_valid() method. Since sPAPR is in big endian configuration at reset, use the big endian LD/ST API to access the hash PTEs. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Nicholas Piggin --- hw/ppc/spapr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4845bf3244b..b67ab1ee685 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1406,7 +1406,11 @@ static uint64_t *hpte_get(SpaprMachineState *s, unsigned index) return &table[2 * index]; } -#define HPTE_VALID(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_VALID) +static bool hpte_is_valid(SpaprMachineState *s, unsigned index) +{ + return ldq_be_p(hpte_get(s, index)) & HPTE64_V_VALID; +} + #define HPTE_DIRTY(_hpte) (tswap64(*((uint64_t *)(_hpte))) & HPTE64_V_HPTE_DIRTY) #define CLEAN_HPTE(_hpte) ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY)) #define DIRTY_HPTE(_hpte) ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY)) @@ -2204,7 +2208,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr, /* Consume invalid HPTEs */ while ((index < htabslots) - && !HPTE_VALID(hpte_get(spapr->htab, index))) { + && !hpte_is_valid(spapr->htab, index)) { CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; } @@ -2212,7 +2216,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr, /* Consume valid HPTEs */ chunkstart = index; while ((index < htabslots) && (index - chunkstart < USHRT_MAX) - && HPTE_VALID(hpte_get(spapr->htab, index))) { + && hpte_is_valid(spapr->htab, index)) { CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; } @@ -2262,7 +2266,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, /* Consume valid dirty HPTEs */ while ((index < htabslots) && (index - chunkstart < USHRT_MAX) && HPTE_DIRTY(hpte_get(spapr->htab, index)) - && HPTE_VALID(hpte_get(spapr->htab, index))) { + && hpte_is_valid(spapr->htab, index)) { CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; examined++; @@ -2272,7 +2276,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, /* Consume invalid dirty HPTEs */ while ((index < htabslots) && (index - invalidstart < USHRT_MAX) && HPTE_DIRTY(hpte_get(spapr->htab, index)) - && !HPTE_VALID(hpte_get(spapr->htab, index))) { + && !hpte_is_valid(spapr->htab, index)) { CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; examined++;