From patchwork Thu Nov 2 01:29:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 740366 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp594800wrv; Wed, 1 Nov 2023 18:36:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLpxXJdUKbD/3SlU4YW+3RY2FG/pfVR1rVVM2YDTJ8RdbCL8sIoxkLELDU4tVnmNlK/LDN X-Received: by 2002:a1f:adce:0:b0:49c:37a1:235b with SMTP id w197-20020a1fadce000000b0049c37a1235bmr12318419vke.7.1698888989809; Wed, 01 Nov 2023 18:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698888989; cv=none; d=google.com; s=arc-20160816; b=xmSPtJFzz5cEuy9cmjmPLlFOWDiEZ2TjI+eq9H6HfKyeLxExRD98URufIWnnib/hB/ QHfyCCm/QHSagcwrq1+XGJ0UazyaI/dnNjU3w5q5NwB4BxwXlSCzxpuWdebe7cWVxnc5 rSo9RGEP03Yuwcak5EG/K60AVfqtZW44zcE5T59BUOegi2lFRBgkTpMYh8ONkdKQEyIl NFIBoIVtchjJpTz+NN5hNjue4YM5obcUgR2O96175UmO6BKsL4uQWGLRLDUDxeie82tg I9Cs6McCxt2/gmqjeGdHW0GBUQaNC7gNLVxlnOzb4ygM48O9iDz+5LI6AXlbuybAjikt lBTQ== 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=LHnqcTd2zYy6MQLA9+Bgtzlrc46QZUrJeWNi/+sdBfc=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=pxMGfrtH2QVDBxlAahK8UyKh2j9ITpHE65g40GGcl9jN9RlT5K7I+YrywA5hjWe/2B g3ZrwZYHbHNGJ9enbXEAva1UgaioAARTtDTRYZaJKSYqxjt2e/6uGkaF3iJcla5QSN75 5MFahh0JCvbuRE9ISKWxYidDgK+/RWikUu7TJ5+FwVSBUHHFs7WMDRXx7/1W1QSN3w7C EzbEt0n/2nBz/DZfyVy/XfCQdPc2av4YPKCF83PccXEovyv0q8Jt3x7uEp8IbmPVCJH5 7eqOQwqTNi/BeV9SblfPuwQ1HbGATV2URtm7jio6EpsFnsQ6MzsXfxK2InP2WAdTBFTs q3xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBCcEeLb; 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 po1-20020a05620a384100b0077586a3f948si3309440qkn.394.2023.11.01.18.36.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Nov 2023 18:36:29 -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=GBCcEeLb; 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 1qyMXr-0005nM-6f; Wed, 01 Nov 2023 21:30:51 -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 1qyMXk-0005kN-J8 for qemu-devel@nongnu.org; Wed, 01 Nov 2023 21:30:44 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyMXi-0001c3-Rt for qemu-devel@nongnu.org; Wed, 01 Nov 2023 21:30:44 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6be1bc5aa1cso487467b3a.3 for ; Wed, 01 Nov 2023 18:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698888641; x=1699493441; 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=LHnqcTd2zYy6MQLA9+Bgtzlrc46QZUrJeWNi/+sdBfc=; b=GBCcEeLbe0ymr0cQrB2N7RtHXOdjy/BbTKMa6UAhh4XtQb46Z9tavYfjW1hpaa3jAx XSTXdy2KPltg51tat39vtrKXE+OMxpZzByJf+7dQ9FceFpyb2ZEs8DgT1JjRmUAWMDVd Wnz8N1HliVZ5XuuRQaENyhgYR6LZzoQXZsYCfiqpMKmur3oQyHOdmE6WzRs3eLEuZwJS LNVwCCR3j5LBbQz1K9DEZZ4hUcljmn8yyPbj6JANiEQbXgCEND/9VEfgedEOajpAvBpp 77B06cFuNG9+Xa5f5z4Ulxr/yjGHftGAt+KGscDZNKI8WYoSB2De+18fgtiUZCgzQPRT aTTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698888641; x=1699493441; 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=LHnqcTd2zYy6MQLA9+Bgtzlrc46QZUrJeWNi/+sdBfc=; b=XoYhBtS8hRN/fg/Xplghijh5UDoEdmwo6YsrAJoaaukJtiBpoi4ZbgdH2B87PRboZc xbQOpmn+EagwL3DtyZgBWBqg2s3O2fJmfI34ss/KaAGwLHpg4k7DxgVIu9vIo2MEt42K U8p5iJMG4TW4JnwAAflzwJNJLz3mGcWeSAUDA3zEfDEoulC/cdUWBa/Y/uEPFs6r+D/O eOyF06ud0OAvUJfyUXn5PYjVkk5h+gU+X5m3WpausDymY8+UH6Wh7VZP9s2lk6zHkqRV 7kjblnOt6hQUDSCf4llyBp2zfUgkq32yJgvZzXJQVqyyVs5BKo4D2N4T8EvsPMFj7Xr4 550w== X-Gm-Message-State: AOJu0YzE9BU11IPBD8y2m0SO5E3lEpFBCdmrcRkRcYrJxZPp7gTchwZW tL8dmld6hYKZb3VK5176TUfu5qFGKrc0yyiKJe4= X-Received: by 2002:a05:6a00:1488:b0:6be:b79:eca with SMTP id v8-20020a056a00148800b006be0b790ecamr21174106pfu.32.1698888640583; Wed, 01 Nov 2023 18:30:40 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id r23-20020aa78457000000b006979f70fdd5sm1784191pfn.219.2023.11.01.18.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 18:30:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v3 24/88] target/hppa: Handle absolute addresses for pa2.0 Date: Wed, 1 Nov 2023 18:29:12 -0700 Message-Id: <20231102013016.369010-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231102013016.369010-1-richard.henderson@linaro.org> References: <20231102013016.369010-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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=ham 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 With pa2.0, absolute addresses are not the same as physical addresses, and undergo a transformation based on PSW_W. Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 3 +++ target/hppa/mem_helper.c | 43 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 301c82114a..2999df9ff9 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -313,6 +313,9 @@ static inline target_ulong hppa_form_gva(CPUHPPAState *env, uint64_t spc, return hppa_form_gva_psw(env->psw, spc, off); } +hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr); +hwaddr hppa_abs_to_phys_pa2_w1(vaddr addr); + /* * Since PSW_{I,CB} will never need to be in tb->flags, reuse them. * TB_FLAG_SR_SAME indicates that SR4 through SR7 all contain the diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 327fb20c17..420b43a0f6 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -25,6 +25,45 @@ #include "hw/core/cpu.h" #include "trace.h" +hwaddr hppa_abs_to_phys_pa2_w1(vaddr addr) +{ + if (likely(extract64(addr, 58, 4) != 0xf)) { + /* Memory address space */ + return addr & MAKE_64BIT_MASK(0, 62); + } + if (extract64(addr, 54, 4) != 0) { + /* I/O address space */ + return addr | MAKE_64BIT_MASK(62, 2); + } + /* PDC address space */ + return (addr & MAKE_64BIT_MASK(0, 54)) | MAKE_64BIT_MASK(60, 4); +} + +hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr) +{ + if (likely(extract32(addr, 28, 4) != 0xf)) { + /* Memory address space */ + return addr & MAKE_64BIT_MASK(0, 32); + } + if (extract32(addr, 24, 4) != 0) { + /* I/O address space */ + return addr | MAKE_64BIT_MASK(32, 32); + } + /* PDC address space */ + return (addr & MAKE_64BIT_MASK(0, 24)) | MAKE_64BIT_MASK(60, 4); +} + +static hwaddr hppa_abs_to_phys(CPUHPPAState *env, vaddr addr) +{ + if (!hppa_is_pa20(env)) { + return addr; + } else if (env->psw & PSW_W) { + return hppa_abs_to_phys_pa2_w1(addr); + } else { + return hppa_abs_to_phys_pa2_w0(addr); + } +} + static HPPATLBEntry *hppa_find_tlb(CPUHPPAState *env, vaddr addr) { IntervalTreeNode *i = interval_tree_iter_first(&env->tlb_root, addr, addr); @@ -222,7 +261,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, } egress: - *pphys = phys; + *pphys = phys = hppa_abs_to_phys(env, phys); *pprot = prot; trace_hppa_tlb_get_physical_address(env, ret, prot, addr, phys); return ret; @@ -238,7 +277,7 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) /* ??? We really ought to know if the code mmu is disabled too, in order to get the correct debugging dumps. */ if (!(cpu->env.psw & PSW_D)) { - return addr; + return hppa_abs_to_phys(&cpu->env, addr); } excp = hppa_get_physical_address(&cpu->env, addr, MMU_KERNEL_IDX, 0,