From patchwork Wed Dec 18 18:21:01 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: 851752 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1078116wrq; Wed, 18 Dec 2024 10:22:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVqQiX1GNM/HcvuDZSXw0qCH6VkrJP2WADhAYkVPnPKWnIoGsemZc1z6g1cy5R9Gs4/RvcXTw==@linaro.org X-Google-Smtp-Source: AGHT+IGvEj/pEXoINJXfBjx1TdQVROKN0Ao0jaN5EGmFSPSuogzcqBF1AMTa7478IwRkYZwY3S/0 X-Received: by 2002:a05:620a:1992:b0:7b3:3657:9e5b with SMTP id af79cd13be357-7b9aaa681b4mr53250185a.26.1734546156357; Wed, 18 Dec 2024 10:22:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734546156; cv=none; d=google.com; s=arc-20240605; b=FSxJpfHP3TIWVexnYcOOzndIjOaDf6cXQvqfHAAKyu7Cu8gtMMM0Tm3Yh7e4lF5Wsn lu4J0WlldFysrSpFAtYw2XXWQ1HmbPo8Dr+OwmXCP7UUapZygNyxfqr4q2BUDEwfHsQq ba6WGJyLJXoNiLABLitRdpSC2mTZy4Scxog4ZzfdPQGJWZjy5/5HH2EoTcgGf0lUPFrl 5Z0PTzt7J89EA3R9E+wRE8Ew617Q087dfvbJTkzTgASbkOHq4fVyu3xxpKjyoqcOZwcw TcqMy+wju/cazncL3+Dd9pMsA81YKB3AsAUyoXHJABDvHBkoZ8JKFSnuRYbRrtWrBgnH 5OuA== 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=eQzhvPTiN3ivier5WU2Y9S2wBlcJwBk1Bj+vHdELx1w=; fh=aDK3AYW/tYhipRsN4fimbcHK1l9GCjVTlWyiAdYPq8A=; b=IN2IX7LzVNd7+ym5BQV+NixiX2p3pKjJiyaK/APLdc3/GtCH2qUTt8NnbhmIlb6yQO E7jF9/MDP0CwBP34pcTKJMcNPTYdP8k8CWLgEITfgP6dTGXeG6/nAciiY6TnrhPALCi3 PAvc2kWJKEH1YC1OSYfBh19SlCRfQlvGRkHahPYplTpV1ErBJeTShnZCDaqW1giWlXOy rYXPCq5IgjYiuqe7OIznxPn/TBE9ydzxmXRaGjYJrKoT41K7f3HYuQVL7w3mjvX9t2oc 6KmRZqplzqqily+jKkAwETnvja64CN8uJNdoLyCDOHIzhWQUfSnlnpzyWphSj0v0s89W aIjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pCZ52Q0X; 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-7b7048cc789si1247596085a.372.2024.12.18.10.22.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Dec 2024 10:22:36 -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=pCZ52Q0X; 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 1tNyfk-0000Aw-CP; Wed, 18 Dec 2024 13:21:24 -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 1tNyfi-0000AQ-9Z for qemu-devel@nongnu.org; Wed, 18 Dec 2024 13:21:22 -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 1tNyfg-0001lW-CO for qemu-devel@nongnu.org; Wed, 18 Dec 2024 13:21:21 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361f796586so75055425e9.3 for ; Wed, 18 Dec 2024 10:21:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734546078; x=1735150878; 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=eQzhvPTiN3ivier5WU2Y9S2wBlcJwBk1Bj+vHdELx1w=; b=pCZ52Q0XA4V4Zhs2dMpJETiMJZDmnulUfl5FOdn7+7yp6JPG8ci3Z6o2O5AKPYpSFE SjyT990rWaAqpB+NWCjOZualCeMp0Or37Gd3g4uXMurkMBwAq1Q3r0lxBwmpRXGwr8CV JLALKRB7rReh0IO+aTc/jEfd4OqN7b76MnHUV4jRWS9BfTwmbUDwG395PiJjxzwy1KvY /HullH9rniHli/fGJPogkW/N9ZgCHvkAwogz7B53BnQZgRTOQudt7gaTfgXuAxkmykxn OYmOOTBBlW7NbycikHfxws+8rxPRbksoIV2WKSmCgmLoWLWzs97IUb8WhUUIGh9qcZel NqQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734546078; x=1735150878; 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=eQzhvPTiN3ivier5WU2Y9S2wBlcJwBk1Bj+vHdELx1w=; b=ffAgubOz30fUpEbcSdatEJYJPUT2h3QANq6SqcoV4M47d5WZ6HHGFTVTtH8UBnakTs s7fuKFcTHS64/IHPSiAZu2dSp1HLixJpy7Kem7YGbWZKmfHYoxvmurkAsI5WZ/cXs9uM nNL8OpMB8fKgPlLzEF8lcCisbi7QclxMGFbsRECwDchVzeFjsJHdFEhCCg7EeuYF6e0k zGSd8Zq8B5py/AklWYyGNCFHxPoP0Mx3AlotZCTWx0fAiRxf2jh7ovZfkkKPUVRIj6Et IKarlzCJuFeftq88Wax1URFvGGSrrWGzEsiQH1BJ/b29HaSNrNId5ul9oc2jsAlg6iHG xF5g== X-Gm-Message-State: AOJu0Yyk0JTKSzf8uxj0EP0CyrR115o+cZUmzuZAjXWT3syU/IHp64K8 vC9RoHyz+xVg9r9aGly9El53u5ut3SLS2I7Q7pzJwrV4AudKt+gs7uEICSQ+KZNT/zXO8T7H4dL N X-Gm-Gg: ASbGnctCYqemzcYKUMasa/n8mnRgvxOEKWnv2755iGSZydQbxgMjna58RERJpdiqHTi CvTky3UNKCq0BlqKypOgxCv8vSTta2s4c/cQY+viWGXa8JILMcLX5x+ZhOs7/4WtdztinVtfuhs 2wP33zMSCYz4btACCZVsO09hRgEW3RklLX1RVuhBSa98zA0Dts/4OZaFp1ZZS83z9+lB5qahmte X3SAxtZNW+izKrgSRGlYItdAkB4a6O+RDo6RggXutcFplYlw3zucZ5X0PDUs9XKKid2kbVaGLnG sUeN X-Received: by 2002:a05:600c:1c21:b0:434:f131:1e71 with SMTP id 5b1f17b1804b1-4365c780d16mr3163225e9.8.1734546078401; Wed, 18 Dec 2024 10:21:18 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4365d116d8fsm1106755e9.17.2024.12.18.10.21.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 10:21:17 -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 2/7] hw/ppc/spapr: Convert HPTE() macro as hpte_get() method Date: Wed, 18 Dec 2024 19:21:01 +0100 Message-ID: <20241218182106.78800-3-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() macro as hpte_get() method. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Nicholas Piggin --- hw/ppc/spapr.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3b022e8da9e..4845bf3244b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1399,7 +1399,13 @@ static bool spapr_get_pate(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu, } } -#define HPTE(_table, _i) (void *)(((uint64_t *)(_table)) + ((_i) * 2)) +static uint64_t *hpte_get(SpaprMachineState *s, unsigned index) +{ + uint64_t *table = s->htab; + + return &table[2 * index]; +} + #define HPTE_VALID(_hpte) (tswap64(*((uint64_t *)(_hpte))) & 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)) @@ -1614,7 +1620,7 @@ int spapr_reallocate_hpt(SpaprMachineState *spapr, int shift, Error **errp) spapr->htab_shift = shift; for (i = 0; i < size / HASH_PTE_SIZE_64; i++) { - DIRTY_HPTE(HPTE(spapr->htab, i)); + DIRTY_HPTE(hpte_get(spapr->htab, i)); } } /* We're setting up a hash table, so that means we're not radix */ @@ -2172,7 +2178,7 @@ static void htab_save_chunk(QEMUFile *f, SpaprMachineState *spapr, qemu_put_be32(f, chunkstart); qemu_put_be16(f, n_valid); qemu_put_be16(f, n_invalid); - qemu_put_buffer(f, HPTE(spapr->htab, chunkstart), + qemu_put_buffer(f, (void *)hpte_get(spapr->htab, chunkstart), HASH_PTE_SIZE_64 * n_valid); } @@ -2198,16 +2204,16 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMachineState *spapr, /* Consume invalid HPTEs */ while ((index < htabslots) - && !HPTE_VALID(HPTE(spapr->htab, index))) { - CLEAN_HPTE(HPTE(spapr->htab, index)); + && !HPTE_VALID(hpte_get(spapr->htab, index))) { + CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; } /* Consume valid HPTEs */ chunkstart = index; while ((index < htabslots) && (index - chunkstart < USHRT_MAX) - && HPTE_VALID(HPTE(spapr->htab, index))) { - CLEAN_HPTE(HPTE(spapr->htab, index)); + && HPTE_VALID(hpte_get(spapr->htab, index))) { + CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; } @@ -2247,7 +2253,7 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, /* Consume non-dirty HPTEs */ while ((index < htabslots) - && !HPTE_DIRTY(HPTE(spapr->htab, index))) { + && !HPTE_DIRTY(hpte_get(spapr->htab, index))) { index++; examined++; } @@ -2255,9 +2261,9 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, chunkstart = index; /* Consume valid dirty HPTEs */ while ((index < htabslots) && (index - chunkstart < USHRT_MAX) - && HPTE_DIRTY(HPTE(spapr->htab, index)) - && HPTE_VALID(HPTE(spapr->htab, index))) { - CLEAN_HPTE(HPTE(spapr->htab, index)); + && HPTE_DIRTY(hpte_get(spapr->htab, index)) + && HPTE_VALID(hpte_get(spapr->htab, index))) { + CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; examined++; } @@ -2265,9 +2271,9 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMachineState *spapr, invalidstart = index; /* Consume invalid dirty HPTEs */ while ((index < htabslots) && (index - invalidstart < USHRT_MAX) - && HPTE_DIRTY(HPTE(spapr->htab, index)) - && !HPTE_VALID(HPTE(spapr->htab, index))) { - CLEAN_HPTE(HPTE(spapr->htab, index)); + && HPTE_DIRTY(hpte_get(spapr->htab, index)) + && !HPTE_VALID(hpte_get(spapr->htab, index))) { + CLEAN_HPTE(hpte_get(spapr->htab, index)); index++; examined++; } @@ -2449,11 +2455,11 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id) if (spapr->htab) { if (n_valid) { - qemu_get_buffer(f, HPTE(spapr->htab, index), + qemu_get_buffer(f, (void *)hpte_get(spapr->htab, index), HASH_PTE_SIZE_64 * n_valid); } if (n_invalid) { - memset(HPTE(spapr->htab, index + n_valid), 0, + memset(hpte_get(spapr->htab, index + n_valid), 0, HASH_PTE_SIZE_64 * n_invalid); } } else {