From patchwork Fri Dec 20 21:30:59 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: 852464 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2288906wrq; Fri, 20 Dec 2024 13:32:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWKvYQ6XgQRgEJ5fOobLxTLu9W5IuwX7wx327Dtcz0iQMnuWBfVjc1w6ADFYO4XfNgRh/af7A==@linaro.org X-Google-Smtp-Source: AGHT+IEGrDzUGgCC9+JYSuLktucI6//LNwUTD7nagI2R3wRx2z/iZKKuTpEUt3Zcn1JI7y9ls8FN X-Received: by 2002:a05:6214:da2:b0:6d8:861f:add0 with SMTP id 6a1803df08f44-6dd2339db8emr65598076d6.31.1734730333933; Fri, 20 Dec 2024 13:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734730333; cv=none; d=google.com; s=arc-20240605; b=kiDrZjzzrdeta2rWAQsI6GW5lTM/SGgcSk+Bkncq+uJiVhDU2jEBgO/gxZKLlU6PgE naxY/es78dlirypvFJEwvvqmzHmdydwrTcCfHGlOFHqvy4mxiwnjFPQIouCoes+Myq/B jmz7ZEvgHs3uQVAh0jxcNWj/C3wJB7LEVBny8qTXPhLIJj48qwT1Z50VnV/JjVVFDqP0 yhFWu4X43yAvy5buuhgr53mwVSgc0H0AmWI7zNO4zBfX/OW199Sn8FOku8aM6XUBqBlf GE+eV9FnKWpmcxFD1mQyh/eWrhByPYGx6gE2eIe5dE07XRsbZmLU6DGP+LhqIWqTREA+ dbkg== 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=aYPfEaXLXgiDntyIsctMYItfQ3K/JB1eh75nxaA67GU=; fh=yNkaL6iJ4UGZubT5jP4totJNhnk+FwlqyNNVT/x++mk=; b=JEZnswfBAWcqCoNsN+rmJ9iTznAZ8SjlOnuCGRWc9jYX6D2jSbqDI2+AFT4jBm4Gnr 5y+3oLhZoz+D5rImJ8rqby+M/CNcIboLOG2kLN/Efrfe5iWnyrbW6mxS4kpveGtBVK8b Om9Uk9+AULNbNA7+IooVFzU5jeWe3G5hHUaiPX+873XKPi3vptTt6H4/OaNZ7rkifywO 7jVr1C+yHAYTtQZgQemu6H5WKvGKckM3Ql2fCqCnrPQBRSE5h6dWQVcOmMpb7B4uIpjn Cy+EL5FG6KW79o+eqwjJ5UxAyng1M6FJYbQVXgVt6AsiLrw177A7h5rzGr2xGPMHFoEk p7jQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GqQ1K9V3; 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-6dd18233622si51857286d6.253.2024.12.20.13.32.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2024 13:32:13 -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=GqQ1K9V3; 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 1tOkbN-0005QS-K0; Fri, 20 Dec 2024 16:32:05 -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 1tOkae-0004fi-BJ for qemu-devel@nongnu.org; Fri, 20 Dec 2024 16:31:24 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOkab-000746-TG for qemu-devel@nongnu.org; Fri, 20 Dec 2024 16:31:19 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-43618283d48so17501305e9.1 for ; Fri, 20 Dec 2024 13:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734730275; x=1735335075; 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=aYPfEaXLXgiDntyIsctMYItfQ3K/JB1eh75nxaA67GU=; b=GqQ1K9V3Sa2BZuRoTrWKGCcmXpF6XGfyS3GAzrkuafaZoeqTeo7Y8QKWdIV0ebo/k3 sEVrRDhVThlVUsJ2X31Gism1tG6mDf9uXVVQ1lIJSBce+P/50JkPzaTedaqPeum5kvGz /fAgdrkdOxcfPLtyT3N2y3wFF33N/amBMmxVhEftQczp3XMze25qrgCREQOoGL6nYEGL gEHJfQGcBzlORmsZTkxIUnRa2wxGyw1DPkuQAPExzS0j4Qkcymh/Ezno7Zcuhxjo7dho b/3+VEnu1X5u+W0HRM5cbJFeTbK7iUIR+8XBqYLD2IzXPC5EMX7N9b5Mg1n6NH2L7oax o0Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734730275; x=1735335075; 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=aYPfEaXLXgiDntyIsctMYItfQ3K/JB1eh75nxaA67GU=; b=E4wtKXUtJJQNGZlq1rtZMRfye1PssJbVQxMnP7UKI199/+hhBApyRR3ZpyawhCgULt Y3Pg4uXUT7Vx3Tx8Yx8+X6A+YDnjXPs43EzYBw4z1IK6PQ21TeHhXU27EO6wYeLBefSR +ydiKJ/vXwidFsmHQhgWA21dP9Il207SpyjlIpLZQ8uIlCgMwCGP2X2H0kDAk++05+LV IOfH1auJTMeGJaGngnFotX6xlOekSsLgg3LStyGTUJeS8XPt2pQ720vWKgtca4VxbDoT MQW8OCFdUbFckNrNP52K2TvtMqTFUpAm11oyj5G3+9EPqBgIFQuDvRssQPbMjVEpEoKO Yovw== X-Gm-Message-State: AOJu0YzkWjxLIYFJN+P0LfR6yk3o3r3m7/ykNXki3EEk9rpU3AXRaAKL qcTWyYPkqqi4L6WNuRvA8ti5Xq0KkqLE9OoGY2Pys1DjJFN+WZubGCKJ0QnzcQKhuVJhZsxixI+ F X-Gm-Gg: ASbGncsxtapshCKXkIl+rOQPIL0fbL4RQoylJhKjre5z5E/ru/Cicnni/qL18SrWs9/ +7zaRzY12svdc5cCqDmoKWRW1BQW2Z+6OQdHS9Ou5sKtwakOETqezTStvHSF9pIlC7tKkXozgRL 4q6kOj27z1s/oHNw717P6c7Z5tRPhzh3R+EOiA4AHRv+9X5xBkzdhBSMYwz39cv9C8sqv3/FjTu uzLsg0/JkARdWlJdOZIQdi2nQbk2tloz3DQbiDpufeghmcjc/w+2T5HgOBAJbOHJsmuzp7qO5g= X-Received: by 2002:a05:600c:19c6:b0:434:f2bf:1708 with SMTP id 5b1f17b1804b1-4366854740fmr35398435e9.7.1734730275144; Fri, 20 Dec 2024 13:31:15 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43661200ae5sm55589035e9.17.2024.12.20.13.31.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Dec 2024 13:31:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-ppc@nongnu.org, Harsh Prateek Bora , BALATON Zoltan , Daniel Henrique Barboza , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PATCH v4 2/6] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method Date: Fri, 20 Dec 2024 22:30:59 +0100 Message-ID: <20241220213103.6314-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220213103.6314-1-philmd@linaro.org> References: <20241220213103.6314-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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. sPAPR data structures including the hash page table are big-endian regardless of current CPU endian mode, so 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 bed60afbe22..43220e93c4b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1406,7 +1406,11 @@ static uint64_t *hpte_get_ptr(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_ptr(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_ptr(spapr, index))) { + && !hpte_is_valid(spapr, index)) { CLEAN_HPTE(hpte_get_ptr(spapr, 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_ptr(spapr, index))) { + && hpte_is_valid(spapr, index)) { CLEAN_HPTE(hpte_get_ptr(spapr, 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_ptr(spapr, index)) - && HPTE_VALID(hpte_get_ptr(spapr, index))) { + && hpte_is_valid(spapr, index)) { CLEAN_HPTE(hpte_get_ptr(spapr, 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_ptr(spapr, index)) - && !HPTE_VALID(hpte_get_ptr(spapr, index))) { + && !hpte_is_valid(spapr, index)) { CLEAN_HPTE(hpte_get_ptr(spapr, index)); index++; examined++;