From patchwork Sat Oct 5 15:25:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823315 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D6FA1EB36 for ; Sat, 5 Oct 2024 15:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141955; cv=none; b=o3ZLDf6SDLL36Lr6N1/qIrUtfPzpjr2DU8PTilKlh2VSLer+M0sv/33maqczmMD1ccLVudLCBnB43ifQRgAffDisaHlzp+/rAi8uXDwCXEWjwAatcF5DeqKESo6IwyiGpYual0sG5VhGGbrABPpzGYJU689YDSuMPauArk3dmvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141955; c=relaxed/simple; bh=+dpu25dlok+GjgsLvrO8ITZP/Q4KUk6jRMPM9e4O+S4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uHMnT7fiiFs6fHj1tifqxopuUIZqW/vijLo9soLc0sF9bg6En16XzEoII7iwgUdWRMo9beXWrKG2GkW9GdiSPHyIA25BfenfTFvPHpJy/QS9yHAE+qhIPkQTE4dDpDU67O3fx0/f5aexj78nudWWWnR61uULiJxjTz8qaGywFeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=wVcoYtKq; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wVcoYtKq" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20b90ab6c19so33844305ad.0 for ; Sat, 05 Oct 2024 08:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141954; x=1728746754; darn=vger.kernel.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=Qpc+gtvz4QF2D7U7hwk6I/PwDTmOhNNc5A8A2G2CqV8=; b=wVcoYtKqZhGBLs2DDdD4i0+9MbvlaPnP7NdXl+QxxpoSdo+Nt+RlsoMMOzY6J8wSNc tbfDIfAca0tFkfhmT3ovql0ezzVAcRrYxJTLyVFaOdOtNkXebF4AbUsKEKLRTCpSQsbu P/Nvbxg+CG8yOx834EDBJ58h3O8QZ2yED2McHBnFNUrqDMfLqNSDvOQL4KXtoBVd8DE7 8AW5r1JDuUHvZQ41W9LzA3ulMOZ6IqI2Z8Vx2jisOP1Yg5ujuNb4nHegl2mTewLDcRdz QXozZ3etpzSH1XgH4p4d4ZprpsTRxX+QhboX5nfx76VgErTf2v8b8M+qSXehYBrs++Tu soIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141954; x=1728746754; 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=Qpc+gtvz4QF2D7U7hwk6I/PwDTmOhNNc5A8A2G2CqV8=; b=mT7bAK00RDdYpcD8V2zY0fL3N3Qt51oMPR3l+4MupZ8JHJdDiftdoYO0l/FcoxQ2IZ nX4Juj233Cxo5T2+n91vjC8BGBHLKCcSwonFXSIM4IbOSifvjtzvfr5QqiXf+DdlYwXw FQzM5RQq5ITxSlk9qbCRkeYW3ggTI90EvRQIfgPcPHMJzO0/BaK67o7ys0CxtbGfq0If ZjaS0eD54vX/yA9q/7vvMBoB37CJ7hliyIHZURIJQsyCJ9KQvqg5MSdFYsJy4VqfWJJy +LeFua8NxJj7Dm+wrlauoDHVK+D72hvssjRG9XZCwaX57SxE5OdbRCVzn1CsTM7aVTXB H6qg== X-Forwarded-Encrypted: i=1; AJvYcCV4WO/WiH0HG/QqeIHLtYG65+Oc7TkkZ/46eZDD70W4LzQx/81e1e8SGsgK92tfdmupw/tIfOs5dZDYJK8=@vger.kernel.org X-Gm-Message-State: AOJu0YzfEcoy9foIYdcFNmPfA7l0nacRxxg6j+3vtpSCJKQ+kayhnSwY ye828CkFr3Pn5OgINHn2BPPwlgNfTTqFoiUpaud8kHFCeNjYBh9sRc9ThSl/rJk= X-Google-Smtp-Source: AGHT+IELKa52UOR7Ytz4WC8NdW2qQ7qz0VWYMH9P15Fb5pfsJzTN9y4328hD9lJpQGFW7j/3iwlUjQ== X-Received: by 2002:a17:902:f68f:b0:20b:54cc:b34e with SMTP id d9443c01a7336-20bfee34d54mr84315875ad.51.1728141953851; Sat, 05 Oct 2024 08:25:53 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 01/20] accel/tcg: Assert noreturn from write-only page for atomics Date: Sat, 5 Oct 2024 08:25:32 -0700 Message-ID: <20241005152551.307923-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There should be no "just in case"; the page is already in the tlb, and known to be not readable. Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 117b516739..fd6459b695 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1852,10 +1852,9 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, /* * Since we don't support reads and writes to different * addresses, and we do have the proper page loaded for - * write, this shouldn't ever return. But just in case, - * handle via stop-the-world. + * write, this shouldn't ever return. */ - goto stop_the_world; + g_assert_not_reached(); } /* Collect tlb flags for read. */ tlb_addr |= tlbe->addr_read; From patchwork Sat Oct 5 15:25:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823316 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 745891C6A3 for ; Sat, 5 Oct 2024 15:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141957; cv=none; b=o7Qs0ExRO9B2fx+fM9xNmeU7bbSx3dY6Lq9KJhzVEbZdR1YEfSm1ytc0WElX60kRqz+7DTRL3mWnwcu9tiAfCsosEXVWAPYaLivBIwoCoInj10lQiXmpKK3ydptJ6p9IIVNTifCNf7g1/EYl2cLomX/l9xk1LB1af85n9HZiIhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141957; c=relaxed/simple; bh=CsqbOG3MqlbMWcSFdA2BCSBmA0dzoz8OyW/OJILfreQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ekLJgoaA/m3BgssxpAXsDXG8BO0L0gWCzdV2WVebdTZ9eTE/JUAatkVEKah0kMBk1Xs2fKG8dqeot1gw1mKmZnB+73b/+DVXgelJEcuc2AGsmicrujO2TljIiJEmWrwCUZdSKMqYNG4aK7iNAoQVAThOBv/7dB9yUW6f7FhH27U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Gqbw9Xsg; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Gqbw9Xsg" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20b7eb9e81eso37012765ad.2 for ; Sat, 05 Oct 2024 08:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141955; x=1728746755; darn=vger.kernel.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=wBthGFf8BfR2i4dob959bB47CFsEJX0Mf+aRMHd0jM4=; b=Gqbw9Xsgxt/IDnhr3mAWkB4+i1mDauZ8W9x6oYTxMekAI5hbNPmRqriGHPIk78dV8b hCXKm6p7gFOh0q+IHpls9uEbKhRMsb8L9QP+Qna957WTE6iwKz6ewlSAYcwC9UBCAtS/ 9JAVJjkjtMB05v4rSfZjygDps3F0gjzxBDU1sg8ddNmyea7bNYyVolaKpDmWY4XmWwl+ wjbbZAygpRotVRSpM51QhFkn4NSMrDqZoLj25EG2HNLXL6gGmWJ+VcMWVWUT/Hg3DfdD 0r8+Je8PZCstY1aLNPvxU02OXhYFmOfUcy3HOqn/s7/6fov3De0a1ELgyzsEHLm7+PKN txdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141955; x=1728746755; 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=wBthGFf8BfR2i4dob959bB47CFsEJX0Mf+aRMHd0jM4=; b=A4/dWMsQMbU9dRlvc/fGbmPSK22M96toK8UnUMtO3tp2mQkzr5CfHLgJnvhf6Y/lL2 6lkA83A4eeQ/dyBaGIBwZM1IMD02R5c1lI/NBZ/d/6lMcmjcCMEte3hx3ralZ9gG2cdw G5i6RgYI9UqQQDnwaKustxGCPKjYOJZLuETMHX9hFjOo1O/GOlaBnY8afNzNAjAYUXao kEQ8gZtM/YWijEx/1IRZZzaOQE4N/HgV/2ZdzTh7X+4bcANasP5N+6g798VNnl7J8bIE xTUXK+7YhY9eKO9iCLvs+wdimoWy+j8X6FyfTemnw6WWdMetTQd+wtfhiM84SnGA5Ti5 bSsg== X-Forwarded-Encrypted: i=1; AJvYcCUKGE8WXOIWLIeDISLeF5PphHQs/I7LVpplO+qMAiNkYtTMBsRH1Ckp4kK6LfiGCuHzjPDr/v5nM0eo1tk=@vger.kernel.org X-Gm-Message-State: AOJu0Yyxup/TVb69kJrO2fDpHg8UQEJi7pm27rFHu36mrSEDLZ708P8s +pbU+AJAPoYf1SKx0ffVabwSw5lgr+zcB21lsHF7MC3w+262tv/sp1WlpCHeg1U= X-Google-Smtp-Source: AGHT+IH7Xmy/UoZFDozrpGZR2JXAjehjcUEjjy3Gt9EAYcog/cZlmR6Wqao6wjaMYAvpmgnjtSqiEQ== X-Received: by 2002:a17:902:d581:b0:20b:419e:9f15 with SMTP id d9443c01a7336-20bfea570admr86092045ad.46.1728141954795; Sat, 05 Oct 2024 08:25:54 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 02/20] accel/tcg: Expand tlb_fill for 3 callers Date: Sat, 5 Oct 2024 08:25:33 -0700 Message-ID: <20241005152551.307923-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/cputlb.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index fd6459b695..58960969f4 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1220,25 +1220,6 @@ void tlb_set_page(CPUState *cpu, vaddr addr, prot, mmu_idx, size); } -/* - * Note: tlb_fill() can trigger a resize of the TLB. This means that all of the - * caller's prior references to the TLB table (e.g. CPUTLBEntry pointers) must - * be discarded and looked up again (e.g. via tlb_entry()). - */ -static void tlb_fill(CPUState *cpu, vaddr addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) -{ - bool ok; - - /* - * This is not a probe, so only valid return is success; failure - * should result in exception + longjmp to the cpu loop. - */ - ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, - access_type, mmu_idx, false, retaddr); - assert(ok); -} - static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) @@ -1631,7 +1612,10 @@ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, if (!tlb_hit(tlb_addr, addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, access_type, addr & TARGET_PAGE_MASK)) { - tlb_fill(cpu, addr, data->size, access_type, mmu_idx, ra); + bool ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, data->size, + access_type, mmu_idx, + false, ra); + assert(ok); maybe_resized = true; index = tlb_index(cpu, mmu_idx, addr); entry = tlb_entry(cpu, mmu_idx, addr); @@ -1833,8 +1817,10 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, if (!tlb_hit(tlb_addr, addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, MMU_DATA_STORE, addr & TARGET_PAGE_MASK)) { - tlb_fill(cpu, addr, size, - MMU_DATA_STORE, mmu_idx, retaddr); + bool ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, + MMU_DATA_STORE, mmu_idx, + false, retaddr); + assert(ok); index = tlb_index(cpu, mmu_idx, addr); tlbe = tlb_entry(cpu, mmu_idx, addr); } @@ -1848,7 +1834,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * but addr_read will only be -1 if PAGE_READ was unset. */ if (unlikely(tlbe->addr_read == -1)) { - tlb_fill(cpu, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); + cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, MMU_DATA_LOAD, + mmu_idx, false, retaddr); /* * Since we don't support reads and writes to different * addresses, and we do have the proper page loaded for From patchwork Sat Oct 5 15:25:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823317 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C9D91EB36 for ; Sat, 5 Oct 2024 15:25:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141957; cv=none; b=oyh6Zyn2E2FJGuZvSRGmVM78y4On1vengJbVLD+MPHRSI0ODWLiCuBFDgQmY6icBE6btJJWE+bpD2T0bn0WGe3IJLSzZM4K6Oh2OJp7MWHTIr32l34Jn42roecx/7CHhtOQyp7E1aRhm63J1tYdb89QswcbTmdZvVuEnXyFE6qU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141957; c=relaxed/simple; bh=Gh98pY0MAR0Ot832aCn3hg2vuaYiKb/XiJoz+Ma5LyE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DrWsZK2432TWwR/ZaDqkWxuc6JvuN5UMlWHipvzZe0ASnfGYwG+JTylzo9zdKsLS+T9or9vnpgA3c0KoV8kfbNAsHHdp9slBgLQJFKyJq2b1soK3BfWBXFs5ineh/tuQR+2C/DEO2Ttg4jGNVTjCebfL3DnOJ0JmSHvw9JHMEKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AcsM116Q; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AcsM116Q" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20b8be13cb1so33015115ad.1 for ; Sat, 05 Oct 2024 08:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141956; x=1728746756; darn=vger.kernel.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=js9k8IR/cEhAqGc5dKpCioG/n/UgV+piB56d5dg8Aiw=; b=AcsM116QXYltYcI+STcB0uPajr1fwhisA7VzG2P4XVHxCE60wqclAj7sclZme/V0Z4 mYFedTypgvK9dKsMVPVDLjmujXUCuQSnaisr5q5JdXxpuNJtMnJGj4pI5Uv1XDP21ZIn rQpkLGVoIkS23Zp32RfiIGFLgcs4YEGuKj7446Xcyi9Y1h3/k2WdplLqNGNyEGF0PPxp i44D57aMUCAK/R/2eVz9zyX8Ha+CUKnyukMFjCrzwmwe+HWpZm+KTkBqyphf99meeGbs e3GyRlD35tA7RVo/cv4UgtLHvhs6tpPohhTZcRLu2/kborfi8H9Lgc6KltzsE3YqZafi lOZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141956; x=1728746756; 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=js9k8IR/cEhAqGc5dKpCioG/n/UgV+piB56d5dg8Aiw=; b=t21OlM1LtTdgN4o0gSa3kVvt3InQFs0MlhooPqFyryUrTcJ7XlCOYSqwszBgSDhyqj 12EKcWqxCF+FdrTBeuxHc7L6Nm1msLxVzTp/h5AIMunVn5o0eagJc1igADDtSXHfuzNt jM3enk4AiqRXUDQ943vWQronVtWsND6dcBsyxa3PJv+TtY98u1/ImXaGX7/A2OeYohCp 1wOKorG26UAkDsO9VxVL9zC/KGZR1tSFiHCC8mqfWZlOv9n+Q7exoVAw3fpR3uKFFhns RLwfWnxIk1xMU+XB2Qycu+rdBb5Q8J+vtBw//yTzVRk+3yqTxOF11DGWcyKtckPj25He oWzQ== X-Forwarded-Encrypted: i=1; AJvYcCVrNOqt314vTtI4rO+hwvaIK9FGv49tNs3B47RWG8AOFV7WO/PF80V6Lr0a8SnR+UF+EgE3dfaOPB6A4fI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/BcDfaZlBT4ag8oLa/SBXnKDu5hsiEi2wnwUVRfcplVyBZqiV yEKWR/gfAWl4pkXZ87h6PE3qdW11b4M4nGQv84sapAU6QLE3XXezAjWugURWtE4= X-Google-Smtp-Source: AGHT+IGIBBnYzSGfllOqeGB217gC39c6yX53tA6gs3EyjynpH2B/4NzPXZOQfYqQh+wbNxGsQ2aqKA== X-Received: by 2002:a17:902:e551:b0:20b:4875:2c51 with SMTP id d9443c01a7336-20bfe024d5cmr107983235ad.27.1728141955681; Sat, 05 Oct 2024 08:25:55 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 03/20] include/exec/memop: Move get_alignment_bits from tcg.h Date: Sat, 5 Oct 2024 08:25:34 -0700 Message-ID: <20241005152551.307923-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function is specific to MemOp, not TCG in general. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/exec/memop.h | 23 +++++++++++++++++++++++ include/tcg/tcg.h | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index f881fe7af4..97720a8ee7 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -170,4 +170,27 @@ static inline bool memop_big_endian(MemOp op) return (op & MO_BSWAP) == MO_BE; } +/** + * get_alignment_bits + * @memop: MemOp value + * + * Extract the alignment size from the memop. + */ +static inline unsigned get_alignment_bits(MemOp memop) +{ + unsigned a = memop & MO_AMASK; + + if (a == MO_UNALN) { + /* No alignment required. */ + a = 0; + } else if (a == MO_ALIGN) { + /* A natural alignment requirement. */ + a = memop & MO_SIZE; + } else { + /* A specific alignment requirement. */ + a = a >> MO_ASHIFT; + } + return a; +} + #endif diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 21d5884741..824fb3560d 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -281,29 +281,6 @@ static inline int tcg_type_size(TCGType t) return 4 << i; } -/** - * get_alignment_bits - * @memop: MemOp value - * - * Extract the alignment size from the memop. - */ -static inline unsigned get_alignment_bits(MemOp memop) -{ - unsigned a = memop & MO_AMASK; - - if (a == MO_UNALN) { - /* No alignment required. */ - a = 0; - } else if (a == MO_ALIGN) { - /* A natural alignment requirement. */ - a = memop & MO_SIZE; - } else { - /* A specific alignment requirement. */ - a = a >> MO_ASHIFT; - } - return a; -} - typedef tcg_target_ulong TCGArg; /* Define type and accessor macros for TCG variables. From patchwork Sat Oct 5 15:25:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823318 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54A721C6A3 for ; Sat, 5 Oct 2024 15:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141959; cv=none; b=UrJM6i/vlHl0M0Wr0dMSGd+eh3kY4UQwGKfBLYFqrmP+Wd5PRCkh50VuACTRf5A1C0dRat72DdYqdlrEhJmP1GYYkUZ3ttTdChDvpl2WKCL1YKu7+lwmK4u/r3KFkwsdBg+WtMiYm9CNDAGBJYj6snjmF13UrwIeJs1sSqKBNUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141959; c=relaxed/simple; bh=cBxszF6IGuIGwt5QkpXfxb3/BnjVVGgXMOWgr8qhrQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G0cprx/8vpe15d7uww7BP+NLJdKeie09jCUJ92aQUz+oYVJT8kRb6kDFoczvEveQMb9QzLDs6y96KFTA+rXYphHT1sk9RaDTs8OxguWkNNv34Lml2bAk3LrXCNzhlzhsr7YjQMHUB+7sD33QG3SjdgH0WOP6dRbuIgLob0gVFmk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=drumqoR1; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="drumqoR1" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20b7463dd89so33892285ad.2 for ; Sat, 05 Oct 2024 08:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141957; x=1728746757; darn=vger.kernel.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=DH35lHXcbsJC32qCjyMaGZFqdyczAIeo1misqQjkoMQ=; b=drumqoR1+AbClUC4SaerEGg7SPgtdi1a6XO7L9w2X6/XIKuh6w1+ePNjog7m7n+2V2 gav1qqeJY55/PrlclLLeBq58oMZRzvm2Vql5ji8nRDadaDS8QyrCx7PU9j6Iq2JhlAAt 83H2P8bXZk4P/vR+fjxMjGFBn9jlwsoDiKFtNcoEAQ4JPz8j5AOKrT+VrFd6ARzisb74 lqC86P9s1di+049Td0b9DEH/uH1ptOa2dqpoZcELk+06pN9kE7Xwd29IR7lZ4gcBhjuA xaIK/jFCquiJt1pGBN3goHiu8h/SwOEf4cS5vNe3VJKR72yeYUVguit8dUO5rVscA0N4 WkvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141957; x=1728746757; 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=DH35lHXcbsJC32qCjyMaGZFqdyczAIeo1misqQjkoMQ=; b=aCPobzBerwQ41XIWuzwlqsy7WcHPzRgll2/XdurGPrksqUCqE+GVQUiPk2fRt8HDUr Mj9R1VDiZiFhhHZHcVL6zGHO91X5JMX5xBBdpZWPPVCe67mOAm1/zkutvmEckEk47ahC MxTxFU0XZnS3xb5JTyDXmdWq6ugrYeRx2uwOGhkyjTXN4L7G6fMzqhx+b5/UNWH/1Jv0 NRvVZ63Ew2ZWTuvF8QHuVkslu1OCpYphXZj7ZktqF723OXASMIAndTR10uYdq9YCtksw wiWTmO3VOEzYNWUjGnsmG2fDXcY1ddGhd/g0k4U0Jm0beNFwBZGW8vLdcw76lyM4/lx4 7tDA== X-Forwarded-Encrypted: i=1; AJvYcCXX5Zdgp3HVp0ydFZ6opmpQn2PEBPuqiQmASgjhz/1woji34aTMyG4YjU4UxweSsERLxddXm+Ixm2r9FqM=@vger.kernel.org X-Gm-Message-State: AOJu0Yzwivxrk6+r0Dk7Fo/tNj9u6fCnfCobQnw+OMr+cDnrX38Q4FMt 6RwH5Ph7WFceGq8FMhutezNnn6/kp7fsWm2IhQPsIOf8I+xw6aCPz5E0Qua0zn8= X-Google-Smtp-Source: AGHT+IHT5o1cj1/9FCBXAXC0/1+PVD5HvqkowrTIKtKub8G3zTkYo3PO7CJQAs6NH7O9Krc3Ois1eQ== X-Received: by 2002:a17:902:e94e:b0:20b:ce4e:b9e4 with SMTP id d9443c01a7336-20bfe044af6mr97224115ad.29.1728141956662; Sat, 05 Oct 2024 08:25:56 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 04/20] include/exec/memop: Rename get_alignment_bits Date: Sat, 5 Oct 2024 08:25:35 -0700 Message-ID: <20241005152551.307923-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename to use "memop_" prefix, like other functions that operate on MemOp. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/exec/memop.h | 4 ++-- accel/tcg/cputlb.c | 4 ++-- accel/tcg/user-exec.c | 4 ++-- target/arm/tcg/translate-a64.c | 4 ++-- target/xtensa/translate.c | 2 +- tcg/tcg-op-ldst.c | 6 +++--- tcg/tcg.c | 2 +- tcg/arm/tcg-target.c.inc | 4 ++-- tcg/sparc64/tcg-target.c.inc | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index 97720a8ee7..f53bf618c6 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -171,12 +171,12 @@ static inline bool memop_big_endian(MemOp op) } /** - * get_alignment_bits + * memop_alignment_bits: * @memop: MemOp value * * Extract the alignment size from the memop. */ -static inline unsigned get_alignment_bits(MemOp memop) +static inline unsigned memop_alignment_bits(MemOp memop) { unsigned a = memop & MO_AMASK; diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 58960969f4..b5bff220a3 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1693,7 +1693,7 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, tcg_debug_assert(l->mmu_idx < NB_MMU_MODES); /* Handle CPU specific unaligned behaviour */ - a_bits = get_alignment_bits(l->memop); + a_bits = memop_alignment_bits(l->memop); if (addr & ((1 << a_bits) - 1)) { cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); } @@ -1781,7 +1781,7 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, { uintptr_t mmu_idx = get_mmuidx(oi); MemOp mop = get_memop(oi); - int a_bits = get_alignment_bits(mop); + int a_bits = memop_alignment_bits(mop); uintptr_t index; CPUTLBEntry *tlbe; vaddr tlb_addr; diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 7ddc47b0ba..08a6df9987 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -959,7 +959,7 @@ void page_reset_target_data(target_ulong start, target_ulong last) { } static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr, MemOp mop, uintptr_t ra, MMUAccessType type) { - int a_bits = get_alignment_bits(mop); + int a_bits = memop_alignment_bits(mop); void *ret; /* Enforce guest required alignment. */ @@ -1241,7 +1241,7 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, int size, uintptr_t retaddr) { MemOp mop = get_memop(oi); - int a_bits = get_alignment_bits(mop); + int a_bits = memop_alignment_bits(mop); void *ret; /* Enforce guest required alignment. */ diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 071b6349fc..ec0b1ee252 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -294,7 +294,7 @@ static TCGv_i64 gen_mte_check1_mmuidx(DisasContext *s, TCGv_i64 addr, desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); - desc = FIELD_DP32(desc, MTEDESC, ALIGN, get_alignment_bits(memop)); + desc = FIELD_DP32(desc, MTEDESC, ALIGN, memop_alignment_bits(memop)); desc = FIELD_DP32(desc, MTEDESC, SIZEM1, memop_size(memop) - 1); ret = tcg_temp_new_i64(); @@ -326,7 +326,7 @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); - desc = FIELD_DP32(desc, MTEDESC, ALIGN, get_alignment_bits(single_mop)); + desc = FIELD_DP32(desc, MTEDESC, ALIGN, memop_alignment_bits(single_mop)); desc = FIELD_DP32(desc, MTEDESC, SIZEM1, total_size - 1); ret = tcg_temp_new_i64(); diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 75b7bfda4c..f4da4a40f9 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -521,7 +521,7 @@ static MemOp gen_load_store_alignment(DisasContext *dc, MemOp mop, mop |= MO_ALIGN; } if (!option_enabled(dc, XTENSA_OPTION_UNALIGNED_EXCEPTION)) { - tcg_gen_andi_i32(addr, addr, ~0 << get_alignment_bits(mop)); + tcg_gen_andi_i32(addr, addr, ~0 << memop_alignment_bits(mop)); } return mop; } diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index 23dc807f11..a318011229 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -45,7 +45,7 @@ static void check_max_alignment(unsigned a_bits) static MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st) { - unsigned a_bits = get_alignment_bits(op); + unsigned a_bits = memop_alignment_bits(op); check_max_alignment(a_bits); @@ -559,7 +559,7 @@ static void tcg_gen_qemu_ld_i128_int(TCGv_i128 val, TCGTemp *addr, TCGv_i64 ext_addr = NULL; TCGOpcode opc; - check_max_alignment(get_alignment_bits(memop)); + check_max_alignment(memop_alignment_bits(memop)); tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); /* In serial mode, reduce atomicity. */ @@ -676,7 +676,7 @@ static void tcg_gen_qemu_st_i128_int(TCGv_i128 val, TCGTemp *addr, TCGv_i64 ext_addr = NULL; TCGOpcode opc; - check_max_alignment(get_alignment_bits(memop)); + check_max_alignment(memop_alignment_bits(memop)); tcg_gen_req_mo(TCG_MO_ST_LD | TCG_MO_ST_ST); /* In serial mode, reduce atomicity. */ diff --git a/tcg/tcg.c b/tcg/tcg.c index 34e3056380..5decd83cf4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -5506,7 +5506,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) static TCGAtomAlign atom_and_align_for_opc(TCGContext *s, MemOp opc, MemOp host_atom, bool allow_two_ops) { - MemOp align = get_alignment_bits(opc); + MemOp align = memop_alignment_bits(opc); MemOp size = opc & MO_SIZE; MemOp half = size ? size - 1 : 0; MemOp atom = opc & MO_ATOM_MASK; diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 3de5f50b62..56072d89a2 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1587,7 +1587,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg datalo, tcg_debug_assert((datalo & 1) == 0); tcg_debug_assert(datahi == datalo + 1); /* LDRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64) { + if (memop_alignment_bits(opc) >= MO_64) { if (h.index < 0) { tcg_out_ldrd_8(s, h.cond, datalo, h.base, 0); break; @@ -1691,7 +1691,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo, tcg_debug_assert((datalo & 1) == 0); tcg_debug_assert(datahi == datalo + 1); /* STRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64) { + if (memop_alignment_bits(opc) >= MO_64) { if (h.index < 0) { tcg_out_strd_8(s, h.cond, datalo, h.base, 0); } else { diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 176c98740b..32f9ec24b5 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -1133,7 +1133,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, * Otherwise, test for at least natural alignment and defer * everything else to the helper functions. */ - if (s_bits != get_alignment_bits(opc)) { + if (s_bits != memop_alignment_bits(opc)) { tcg_debug_assert(check_fit_tl(a_mask, 13)); tcg_out_arithi(s, TCG_REG_G0, addr_reg, a_mask, ARITH_ANDCC); From patchwork Sat Oct 5 15:25:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823319 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 413061EB36 for ; Sat, 5 Oct 2024 15:25:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141959; cv=none; b=ELGrLU3xy7VIPW8UA5rJOWbgiDSen7bG6vtk4iJ0UPHWQhUCID0ddGlAnj+gB/l4YxO0utgR05vmrWDop92KcQS1bROHhgGfEtUmVEeUWI0v1iRhEwE1T6Sr1RuMnZUkyxi5XXlHmLefj4OmAkVhlIePOs1g1NwSXj2qTdPPTjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141959; c=relaxed/simple; bh=CNQPVBhItRPAxhRnqCnm3EiuHXwFUY2vwcYaZEAIlXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QsH69fGTF0/JZ674h6/jHKQeAVmdq9NiwrHVrpVuvkHRnZ6gmJcW6asIr1iGXXm/rGdBA+eiqXSwdaBPTQcEuPlqoReWD0OZdbPHpMYsDyzunShMIs5EDgtJeJULlIsl03pYDh+SJ0w7keYcuh86PTXBBk9Mtifg6z+S7swexgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=uNzD32SK; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uNzD32SK" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b6458ee37so36306315ad.1 for ; Sat, 05 Oct 2024 08:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141957; x=1728746757; darn=vger.kernel.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=rMIQXnxelIQ86qxYbOA8sg/WFq9fqYpMUetqZ1DDKfA=; b=uNzD32SK4jsqSh7sLLGNgbPiy/0W3mxuPJySTlhdz8w1CE+KYEN3iQiAofsmbDc4mm GH3uqDwQzkFG5WUSRpPn+lzDjNXAMlZVpDMj+wwf4/hQQIBvIQyzDLtzvP1Cwk0yAxaw uOs2BedVJX6b3bw2vHrgOooJ6+BQo9LwBuzMj2DV3360TZeGtiFE5c5zmllntj2wPGsP w/AqtF5vpm56XCwdnS97+0bX2iXaRW66R8d7mPjibpzZl69KHTWKon7/w1m6Sxezlgsv MBxNZW0CYmMqbtcwdvf8xW7hiXfQ/ynaFPeKbzGVid6h8fbAt+ieE96NjmhHsEozkIqb wskQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141957; x=1728746757; 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=rMIQXnxelIQ86qxYbOA8sg/WFq9fqYpMUetqZ1DDKfA=; b=eVXgGDUKG17+h9Y/zDnTAObHyLErYoqc4pK7uMiHuu9/IlKQ6hPX3QhW0hk7uR+zX4 EDPnp8kwLdZu47pW3ICMxWjn1uxNVS2Ycu/JxHOr/3AS44GQhRiiQ/W84odU40GGWGc4 Bh7+5pIyMlCKAQ/pJS0Rr3f+woPT5HgdKClevXYPVsevCVNC8CfSN0gZXgR0FWERBpEL ftHXOP0AUKmBBvq4P7hzMCdOdmwFyRwgoPO4jgZRiKeqxQrCQFFxoWR+VudYmU4fKNF7 oXoeAO/g6M11kIyOJkAqDD5LTI7z34ZgrR1qwAXnNZV/dzMyIwK9Hiz6vpFXywtAufGX Yr2Q== X-Forwarded-Encrypted: i=1; AJvYcCUVinEDuXGqktu9ipYf7ySU7AzXAhUYtG8Ngkl0HJtCsotO3zaoZdj8sQ9zbXFdqrE5+DGPZ9mH+/DxB64=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4W3kfnzlMsJSlSOEOO2HSK/eE6zg/T0Xjh/ifWjPjJMa/HybL 93zojZuUTHcNLwH8zfSw/coSUpDii8/kD0BFp42EH1aSU9vBmjPQn5rwcIFiCoU= X-Google-Smtp-Source: AGHT+IHCfh10FjkbBSOvqXvOBG9PUScOEcA1SfhVDalzVVmPfKmDc9cmv0jmAUjDnTAXUakJpgurmQ== X-Received: by 2002:a17:902:ec81:b0:20b:90ab:67de with SMTP id d9443c01a7336-20bfde594f1mr78046015ad.8.1728141957612; Sat, 05 Oct 2024 08:25:57 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 05/20] include/exec/memop: Introduce memop_atomicity_bits Date: Sat, 5 Oct 2024 08:25:36 -0700 Message-ID: <20241005152551.307923-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Split out of mmu_lookup. Signed-off-by: Richard Henderson --- include/exec/memop.h | 24 ++++++++++++++++++++++++ accel/tcg/cputlb.c | 16 ++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index f53bf618c6..b699bf7688 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -193,4 +193,28 @@ static inline unsigned memop_alignment_bits(MemOp memop) return a; } +/* + * memop_atomicity_bits: + * @memop: MemOp value + * + * Extract the atomicity size from the memop. + */ +static inline unsigned memop_atomicity_bits(MemOp memop) +{ + unsigned size = memop & MO_SIZE; + + switch (memop & MO_ATOM_MASK) { + case MO_ATOM_NONE: + size = MO_8; + break; + case MO_ATOM_IFALIGN_PAIR: + case MO_ATOM_WITHIN16_PAIR: + size = size ? size - 1 : 0; + break; + default: + break; + } + return size; +} + #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b5bff220a3..f5fca5a118 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1751,20 +1751,8 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * Device memory type require alignment. */ if (unlikely(flags & TLB_CHECK_ALIGNED)) { - MemOp size = l->memop & MO_SIZE; - - switch (l->memop & MO_ATOM_MASK) { - case MO_ATOM_NONE: - size = MO_8; - break; - case MO_ATOM_IFALIGN_PAIR: - case MO_ATOM_WITHIN16_PAIR: - size = size ? size - 1 : 0; - break; - default: - break; - } - if (addr & ((1 << size) - 1)) { + a_bits = memop_atomicity_bits(l->memop); + if (addr & ((1 << a_bits) - 1)) { cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); } } From patchwork Sat Oct 5 15:25:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823320 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68D661C6A3 for ; Sat, 5 Oct 2024 15:25:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141961; cv=none; b=MD5PuzmEI97SSGO4o9zvwoLGQlARyMDgG02AvihP64mOCpp228sGpFxWo/phidJqhdUrvZVCVqMbHXVpXcdmvtpvtPw+3cvO84yz1c7oI8m5k4JnLRBrMM8jsJc8yVk7PqKmH8MJOZJ1wx0lQSalTNUEABD5SfrAMTFm8s0C844= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141961; c=relaxed/simple; bh=QT4L20i/uvGnpQx/+7mQvzKz0ZX1VGWN5uFF3Erquvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hLKO6YDGkxcPV6wiSCvCqv9pubCf5H/4JhnNDmmkV0oIg3d1iowvMGtKTgpugpGV0inAb+q+mhIvM5ICkO3b1OCT9CvF+/VGANnjs/gDelsmFU3Q4NTDa3lZy1kUD1abC8dHV9ReT1j0gKxUwrQfav/SjhyzTuXymWMCexYqh34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=gAG1g78+; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gAG1g78+" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20b93887decso25571375ad.3 for ; Sat, 05 Oct 2024 08:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141959; x=1728746759; darn=vger.kernel.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=1f/qgYd1hp1mLwoixEUX+NfB0hBePURRnKwRiQEkN3A=; b=gAG1g78+9Lv8SCcNiFTsk/Lv9Q+eVUJXZbMLrbxcmRqmB2oPVCfMwMyTnbB4EFRSMc zVqYfGI9SjMT+me/YO1b+hE4eLW4/ScAebSKMrRzFd40/sI4WoYdFIDuj/ID1h1+EW9E MKvUhMs97mIc3lZ66VGIqF0KlFjxA4fKbQewb8+ad730pqX7DJ0vIgTFLYgM8/AJn/Vx DffobeAoXJ1V6EIrmLUMPzu3r1DXb4mmUxmHO1RV4ycR0oC7oYb7AXIUKZ9/hXmR30un J5z782IiPSPnYHq6oW8Xk9Dai3Nr8TmPeFQLvw3RkCu/bYLltIFSwC6I3OR0dd0uutH9 tlzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141959; x=1728746759; 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=1f/qgYd1hp1mLwoixEUX+NfB0hBePURRnKwRiQEkN3A=; b=f9wk2SaavI0HGM4/SSdEg7PMNGe+3u2VMf33e7pp4S5rrKck4Yz9D7pjRhGEDp/2p6 yv1Hc4UkRT7ObJL+8EJW09Z/otvVU4kOPqeNOklbivtwJxkWVZ7vdyBl+RtuPjzZDI8a fSuAYJpUs9vMarED8N9zMXr8iYZx4NpJB8j1SkRz74laYA/WEJxFvkxhX7qkImAAvhp6 azzZXuCsQuAYz+zDgtNOhJ5wmVFzCCOj2xA9oAj9DpXCpDZn6DvdbpD+E5JcIe9II4xl uoJ4dB3wtGqCm3N1N4WxkAwLYg7o/6n7aAr/ydE77j5b+jViLVW2mudZ8w8csytpa0Gs NJeg== X-Forwarded-Encrypted: i=1; AJvYcCX02cYk3AUsp9eKCFDYq+DQEvQS69jHV2039SLBvsPy4EFJkUoDo1QiYRNeU8bOHk5M9Gue8sPHPKtStVg=@vger.kernel.org X-Gm-Message-State: AOJu0YwcYY2F1hg9okq6hM2NpSHwgPKL7UEgu2zAJiNo9q+NgIgj6xDv yky1ifB6WN7Qc/Cc3IQDCRJXCbGRWFgFemWZ5baPFv4wnUPH52Ua7IRl9+rE8O0= X-Google-Smtp-Source: AGHT+IFNgJgHqy/VR+xV+JwXb1EIli9R1fK+5kP2TeHrRKEb6qUaztlEMB6BdUtTQMmyRZuU4erYGw== X-Received: by 2002:a17:903:41d1:b0:20b:80e6:bcdf with SMTP id d9443c01a7336-20bfe17e008mr91058345ad.23.1728141958687; Sat, 05 Oct 2024 08:25:58 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 06/20] hw/core/tcg-cpu-ops: Introduce tlb_fill_align hook Date: Sat, 5 Oct 2024 08:25:37 -0700 Message-ID: <20241005152551.307923-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the hook to struct TCGCPUOps. Add a default implementation that recognizes alignment faults before page faults. Populate all TCGCPUOps structures with the default implementation. Signed-off-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 25 +++++++++++++++++++++++++ accel/tcg/cputlb.c | 19 +++++++++++++++++++ target/alpha/cpu.c | 1 + target/arm/cpu.c | 1 + target/arm/tcg/cpu-v7m.c | 1 + target/avr/cpu.c | 1 + target/hppa/cpu.c | 1 + target/i386/tcg/tcg-cpu.c | 1 + target/loongarch/cpu.c | 1 + target/m68k/cpu.c | 1 + target/microblaze/cpu.c | 1 + target/mips/cpu.c | 1 + target/openrisc/cpu.c | 1 + target/ppc/cpu_init.c | 1 + target/riscv/tcg/tcg-cpu.c | 1 + target/rx/cpu.c | 1 + target/s390x/cpu.c | 1 + target/sh4/cpu.c | 1 + target/sparc/cpu.c | 1 + target/tricore/cpu.c | 1 + target/xtensa/cpu.c | 1 + 21 files changed, 63 insertions(+) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 34318cf0e6..49420bc93d 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -13,6 +13,7 @@ #include "exec/breakpoint.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" +#include "exec/memop.h" #include "exec/mmu-access-type.h" #include "exec/vaddr.h" @@ -131,6 +132,21 @@ struct TCGCPUOps { * same function signature. */ bool (*cpu_exec_halt)(CPUState *cpu); + + /** + * @tlb_fill_align: Handle a softmmu tlb miss, and alignment fault + * + * If the access is valid, call tlb_set_page and return true; + * if the access is invalid and probe is true, return false; + * otherwise raise an exception and do not return. + * + * The alignment check is deferred to this hook, so that the + * target can choose to recognize either before or after the + * permission check. + */ + bool (*tlb_fill_align)(CPUState *cpu, vaddr address, MemOp mop, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); /** * @tlb_fill: Handle a softmmu tlb miss * @@ -234,6 +250,15 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, */ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len); +/* + * tlb_fill_align_first: + * + * Prioritize alignment faults over page faults. + */ +bool tlb_fill_align_first(CPUState *cpu, vaddr address, MemOp mop, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + #endif #endif /* TCG_CPU_OPS_H */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index f5fca5a118..4bc34c8a37 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1565,6 +1565,25 @@ bool tlb_plugin_lookup(CPUState *cpu, vaddr addr, int mmu_idx, } #endif + +/* + * Generic implementation of tlb_fill_align which recognizes + * alignment faults before page faults. + */ +bool tlb_fill_align_first(CPUState *cpu, vaddr addr, MemOp mop, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) +{ + unsigned a_bits = memop_alignment_bits(mop); + + if (unlikely(addr & ((1 << a_bits) - 1))) { + cpu_unaligned_access(cpu, addr, access_type, mmu_idx, retaddr); + } + + return cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, access_type, + mmu_idx, probe, retaddr); +} + /* * Probe for a load/store operation. * Return the host address and into @flags. diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 9db1dffc03..2eb5afd34a 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -217,6 +217,7 @@ static const TCGCPUOps alpha_tcg_ops = { .record_sigsegv = alpha_cpu_record_sigsegv, .record_sigbus = alpha_cpu_record_sigbus, #else + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = alpha_cpu_tlb_fill, .cpu_exec_interrupt = alpha_cpu_exec_interrupt, .cpu_exec_halt = alpha_cpu_has_work, diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 19191c2391..08731ed4e0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2663,6 +2663,7 @@ static const TCGCPUOps arm_tcg_ops = { .record_sigsegv = arm_cpu_record_sigsegv, .record_sigbus = arm_cpu_record_sigbus, #else + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = arm_cpu_tlb_fill, .cpu_exec_interrupt = arm_cpu_exec_interrupt, .cpu_exec_halt = arm_cpu_exec_halt, diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c index 5496f14dc1..8874fe0e11 100644 --- a/target/arm/tcg/cpu-v7m.c +++ b/target/arm/tcg/cpu-v7m.c @@ -242,6 +242,7 @@ static const TCGCPUOps arm_v7m_tcg_ops = { .record_sigsegv = arm_cpu_record_sigsegv, .record_sigbus = arm_cpu_record_sigbus, #else + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = arm_cpu_tlb_fill, .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, .cpu_exec_halt = arm_cpu_exec_halt, diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 3132842d56..6ac4434f1d 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -211,6 +211,7 @@ static const TCGCPUOps avr_tcg_ops = { .restore_state_to_opc = avr_restore_state_to_opc, .cpu_exec_interrupt = avr_cpu_exec_interrupt, .cpu_exec_halt = avr_cpu_has_work, + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = avr_cpu_tlb_fill, .do_interrupt = avr_cpu_do_interrupt, }; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 7cf2e2f266..3b6c325e09 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -226,6 +226,7 @@ static const TCGCPUOps hppa_tcg_ops = { .restore_state_to_opc = hppa_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = hppa_cpu_tlb_fill, .cpu_exec_interrupt = hppa_cpu_exec_interrupt, .cpu_exec_halt = hppa_cpu_has_work, diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index cca19cd40e..83cfb86346 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -117,6 +117,7 @@ static const TCGCPUOps x86_tcg_ops = { .record_sigsegv = x86_cpu_record_sigsegv, .record_sigbus = x86_cpu_record_sigbus, #else + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = x86_cpu_tlb_fill, .do_interrupt = x86_cpu_do_interrupt, .cpu_exec_halt = x86_cpu_exec_halt, diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 7212fb5f8f..ae8856d988 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -755,6 +755,7 @@ static const TCGCPUOps loongarch_tcg_ops = { .restore_state_to_opc = loongarch_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = loongarch_cpu_tlb_fill, .cpu_exec_interrupt = loongarch_cpu_exec_interrupt, .cpu_exec_halt = loongarch_cpu_has_work, diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 1d49f4cb23..295ebd941b 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -534,6 +534,7 @@ static const TCGCPUOps m68k_tcg_ops = { .restore_state_to_opc = m68k_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = m68k_cpu_tlb_fill, .cpu_exec_interrupt = m68k_cpu_exec_interrupt, .cpu_exec_halt = m68k_cpu_has_work, diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 135947ee80..6e63600631 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -411,6 +411,7 @@ static const TCGCPUOps mb_tcg_ops = { .restore_state_to_opc = mb_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = mb_cpu_tlb_fill, .cpu_exec_interrupt = mb_cpu_exec_interrupt, .cpu_exec_halt = mb_cpu_has_work, diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 89655b1900..5a36b22256 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -553,6 +553,7 @@ static const TCGCPUOps mips_tcg_ops = { .restore_state_to_opc = mips_restore_state_to_opc, #if !defined(CONFIG_USER_ONLY) + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = mips_cpu_tlb_fill, .cpu_exec_interrupt = mips_cpu_exec_interrupt, .cpu_exec_halt = mips_cpu_has_work, diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 6ec54ad7a6..9223228758 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -231,6 +231,7 @@ static const TCGCPUOps openrisc_tcg_ops = { .restore_state_to_opc = openrisc_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = openrisc_cpu_tlb_fill, .cpu_exec_interrupt = openrisc_cpu_exec_interrupt, .cpu_exec_halt = openrisc_cpu_has_work, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 23881d09e9..42a38ec155 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7482,6 +7482,7 @@ static const TCGCPUOps ppc_tcg_ops = { #ifdef CONFIG_USER_ONLY .record_sigsegv = ppc_cpu_record_sigsegv, #else + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = ppc_cpu_tlb_fill, .cpu_exec_interrupt = ppc_cpu_exec_interrupt, .cpu_exec_halt = ppc_cpu_has_work, diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index dea8ab7a43..42c4ea13af 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -137,6 +137,7 @@ static const TCGCPUOps riscv_tcg_ops = { .restore_state_to_opc = riscv_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = riscv_cpu_tlb_fill, .cpu_exec_interrupt = riscv_cpu_exec_interrupt, .cpu_exec_halt = riscv_cpu_has_work, diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 36d2a6f189..27fc372ca4 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -188,6 +188,7 @@ static const TCGCPUOps rx_tcg_ops = { .initialize = rx_translate_init, .synchronize_from_tb = rx_cpu_synchronize_from_tb, .restore_state_to_opc = rx_restore_state_to_opc, + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = rx_cpu_tlb_fill, #ifndef CONFIG_USER_ONLY diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 4e41a3dff5..8120ddeb5b 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -363,6 +363,7 @@ static const TCGCPUOps s390_tcg_ops = { .record_sigsegv = s390_cpu_record_sigsegv, .record_sigbus = s390_cpu_record_sigbus, #else + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = s390_cpu_tlb_fill, .cpu_exec_interrupt = s390_cpu_exec_interrupt, .cpu_exec_halt = s390_cpu_has_work, diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 8f07261dcf..b03f6dfad8 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -252,6 +252,7 @@ static const TCGCPUOps superh_tcg_ops = { .restore_state_to_opc = superh_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = superh_cpu_tlb_fill, .cpu_exec_interrupt = superh_cpu_exec_interrupt, .cpu_exec_halt = superh_cpu_has_work, diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 54cb269e0a..da1bfad5f0 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -924,6 +924,7 @@ static const TCGCPUOps sparc_tcg_ops = { .restore_state_to_opc = sparc_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = sparc_cpu_tlb_fill, .cpu_exec_interrupt = sparc_cpu_exec_interrupt, .cpu_exec_halt = sparc_cpu_has_work, diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 1a26171590..9d8f8f13d2 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -173,6 +173,7 @@ static const TCGCPUOps tricore_tcg_ops = { .initialize = tricore_tcg_init, .synchronize_from_tb = tricore_cpu_synchronize_from_tb, .restore_state_to_opc = tricore_restore_state_to_opc, + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = tricore_cpu_tlb_fill, .cpu_exec_interrupt = tricore_cpu_exec_interrupt, .cpu_exec_halt = tricore_cpu_has_work, diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index a08c7a0b1f..b0f84403f0 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -232,6 +232,7 @@ static const TCGCPUOps xtensa_tcg_ops = { .restore_state_to_opc = xtensa_restore_state_to_opc, #ifndef CONFIG_USER_ONLY + .tlb_fill_align = tlb_fill_align_first, .tlb_fill = xtensa_cpu_tlb_fill, .cpu_exec_interrupt = xtensa_cpu_exec_interrupt, .cpu_exec_halt = xtensa_cpu_has_work, From patchwork Sat Oct 5 15:25:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823321 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50FF51EB36 for ; Sat, 5 Oct 2024 15:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141961; cv=none; b=eiz7sg+1ZOehCz2FOoMWw1a2kCPP+h3xd6Tw01c/ESnG5Gd2Ov6F66TOYcTDBYjAXmCbKtJGGL1YNjWTOUqQel2uhuO2SAtcPvoxzJXnOgJbhI6TCIwrixKBqY86VuxvYOJcQnzaEQt8l5jcCX6Chmk0OQyjtgQETI+Kr/urdfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141961; c=relaxed/simple; bh=4NVUV6YGGVu0dfDzUFRQNyxQmIfvN5ZZlTdwZgCxg+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=akBi9OfLgOM6wjrtedpFzMXtIPxCLUZM6WXsH/8glomIKZY1KAg4+ni7tpByz5PFatbAzi5UGy6KSlK+A/repeJ1TNDq0TyAnAds2snNGmwMCII4FMRM1FUEedGwi6ia9210hm/9QqfoDJ4DHfHocyPEcZG8FnUgUlJxTjjAXaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fyZ29mI1; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fyZ29mI1" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-20aff65aa37so26630875ad.1 for ; Sat, 05 Oct 2024 08:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141960; x=1728746760; darn=vger.kernel.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=aSpIks7wgvzrdGiSzq/HYW4dr1jFM7gjMRozlRGemJM=; b=fyZ29mI1dsfMmVaZaAFerE5PYV2FowGSw5vZ6oj7tSXk+fgz2FUlAL++16xPaMQzqk Mn8iv8WUduQNaIM6WVS2cXAXWV84MV9+YQp1Qr+U4819XVPDmrxbblh0O4p0Chc1PrVr qWwbHVr/liVN2LLLLJdWec68brY7lL0E+xDhRCZYQkUHlPmsrRT06kZX/WoE6r4I6W5i Z/QSUnfpQgGrUMF+d5caj9cCqmeMR7rVZlrLaUvg9WaFxMlIDgn6FGlEJlYqBBs8aKLi Upm7fOcX2FqpkKWXnI6BjAEhEm8wa5KoiQJCKdXnvojsLC/tyh6HAsJJbMiNNx9Yop12 id7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141960; x=1728746760; 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=aSpIks7wgvzrdGiSzq/HYW4dr1jFM7gjMRozlRGemJM=; b=mdoBLP6wfj96/WgJwoK/ssDBfKf8TdWONEozVm780XfNK9w4ZcBaOeWVcS+9mKhQXM vBKY/iSfgDff6GMqaaq7mJymMmms8l567wNgIcMUagnx6wG84FCIh6Q19BJM7FNVG8H4 jKgJzw7bYK9HAfaVjth+UVGAiNWI5h2Czy5brsu2OkNJgDLDHLIdwwQGI4mG+I5Y3kqy yUkrbhMJ9gKzw1cLHsZKgmfeg07uKxPGRfTZNaIIsO6f0GWarNSMuQgQRVpbDHZGhSdM 6jflm5cdyfG1b1sN4YiFTGuOZww1U8od4jvIOQTRqimJfaHd59ssTv8MFVVn2Ni8ltCU E+6Q== X-Forwarded-Encrypted: i=1; AJvYcCV+zjhoPQ3tCHVBxe8LEXIR7bKPwkpZfdmNZXPs1sIEERq83BGSn1OJBNRRUsdVaX6vcOOAlh1uJWArUos=@vger.kernel.org X-Gm-Message-State: AOJu0Yyp42l++cMcEZdaDoU6G8MI9RXO0y0n9X0tnW1w12kDLs8VMu5Y amNkiGa0gvImumsY0V7hP4xIvc2t8n33/foseFyqJenkNPfCQPX7Q6kP3Eu6fSocqm6fYQvs1gq L X-Google-Smtp-Source: AGHT+IHHBcTpm+lN7YnCUB3+U4K5he75In85ERBx3pFwVufluTULuz7p5KPxpM3Bc//CGD+sBFjKUg== X-Received: by 2002:a17:902:ec89:b0:20b:982e:73d6 with SMTP id d9443c01a7336-20bff043851mr82009865ad.49.1728141959618; Sat, 05 Oct 2024 08:25:59 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 07/20] accel/tcg: Use the tlb_fill_align hook Date: Sat, 5 Oct 2024 08:25:38 -0700 Message-ID: <20241005152551.307923-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When we have a tlb miss, defer the alignment check to the new tlb_fill_align hook. Move the existing alignment check so that we only perform it with a tlb hit. Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 89 +++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 4bc34c8a37..0e6ae65a39 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1616,14 +1616,14 @@ typedef struct MMULookupLocals { * tlb_fill will longjmp out. Return true if the softmmu tlb for * @mmu_idx may have resized. */ -static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, +static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, MemOp memop, int mmu_idx, MMUAccessType access_type, uintptr_t ra) { vaddr addr = data->addr; uintptr_t index = tlb_index(cpu, mmu_idx, addr); CPUTLBEntry *entry = tlb_entry(cpu, mmu_idx, addr); uint64_t tlb_addr = tlb_read_idx(entry, access_type); - bool maybe_resized = false; + bool did_tlb_fill = false; CPUTLBEntryFull *full; int flags; @@ -1631,17 +1631,26 @@ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, if (!tlb_hit(tlb_addr, addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, access_type, addr & TARGET_PAGE_MASK)) { - bool ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, data->size, - access_type, mmu_idx, - false, ra); + bool ok = cpu->cc->tcg_ops->tlb_fill_align(cpu, addr, memop, + data->size, access_type, + mmu_idx, false, ra); assert(ok); - maybe_resized = true; + did_tlb_fill = true; index = tlb_index(cpu, mmu_idx, addr); entry = tlb_entry(cpu, mmu_idx, addr); } tlb_addr = tlb_read_idx(entry, access_type) & ~TLB_INVALID_MASK; } + if (!did_tlb_fill) { + /* We didn't use tlb_fill_align, so alignment not yet checked. */ + unsigned a_bits = memop_alignment_bits(memop); + + if (unlikely(addr & ((1 << a_bits) - 1))) { + cpu_unaligned_access(cpu, addr, access_type, mmu_idx, ra); + } + } + full = &cpu->neg.tlb.d[mmu_idx].fulltlb[index]; flags = tlb_addr & (TLB_FLAGS_MASK & ~TLB_FORCE_SLOW); flags |= full->slow_flags[access_type]; @@ -1651,7 +1660,7 @@ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, /* Compute haddr speculatively; depending on flags it might be invalid. */ data->haddr = (void *)((uintptr_t)addr + entry->addend); - return maybe_resized; + return did_tlb_fill; } /** @@ -1702,7 +1711,6 @@ static void mmu_watch_or_dirty(CPUState *cpu, MMULookupPageData *data, static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, uintptr_t ra, MMUAccessType type, MMULookupLocals *l) { - unsigned a_bits; bool crosspage; int flags; @@ -1711,12 +1719,6 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, tcg_debug_assert(l->mmu_idx < NB_MMU_MODES); - /* Handle CPU specific unaligned behaviour */ - a_bits = memop_alignment_bits(l->memop); - if (addr & ((1 << a_bits) - 1)) { - cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); - } - l->page[0].addr = addr; l->page[0].size = memop_size(l->memop); l->page[1].addr = (addr + l->page[0].size - 1) & TARGET_PAGE_MASK; @@ -1724,7 +1726,7 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, crosspage = (addr ^ l->page[1].addr) & TARGET_PAGE_MASK; if (likely(!crosspage)) { - mmu_lookup1(cpu, &l->page[0], l->mmu_idx, type, ra); + mmu_lookup1(cpu, &l->page[0], l->memop, l->mmu_idx, type, ra); flags = l->page[0].flags; if (unlikely(flags & (TLB_WATCHPOINT | TLB_NOTDIRTY))) { @@ -1743,8 +1745,8 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * Lookup both pages, recognizing exceptions from either. If the * second lookup potentially resized, refresh first CPUTLBEntryFull. */ - mmu_lookup1(cpu, &l->page[0], l->mmu_idx, type, ra); - if (mmu_lookup1(cpu, &l->page[1], l->mmu_idx, type, ra)) { + mmu_lookup1(cpu, &l->page[0], l->memop, l->mmu_idx, type, ra); + if (mmu_lookup1(cpu, &l->page[1], 0, l->mmu_idx, type, ra)) { uintptr_t index = tlb_index(cpu, l->mmu_idx, addr); l->page[0].full = &cpu->neg.tlb.d[l->mmu_idx].fulltlb[index]; } @@ -1770,7 +1772,7 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * Device memory type require alignment. */ if (unlikely(flags & TLB_CHECK_ALIGNED)) { - a_bits = memop_atomicity_bits(l->memop); + unsigned a_bits = memop_atomicity_bits(l->memop); if (addr & ((1 << a_bits) - 1)) { cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); } @@ -1788,34 +1790,18 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, { uintptr_t mmu_idx = get_mmuidx(oi); MemOp mop = get_memop(oi); - int a_bits = memop_alignment_bits(mop); uintptr_t index; CPUTLBEntry *tlbe; vaddr tlb_addr; void *hostaddr; CPUTLBEntryFull *full; + bool did_tlb_fill = false; tcg_debug_assert(mmu_idx < NB_MMU_MODES); /* Adjust the given return address. */ retaddr -= GETPC_ADJ; - /* Enforce guest required alignment. */ - if (unlikely(a_bits > 0 && (addr & ((1 << a_bits) - 1)))) { - /* ??? Maybe indicate atomic op to cpu_unaligned_access */ - cpu_unaligned_access(cpu, addr, MMU_DATA_STORE, - mmu_idx, retaddr); - } - - /* Enforce qemu required alignment. */ - if (unlikely(addr & (size - 1))) { - /* We get here if guest alignment was not requested, - or was not enforced by cpu_unaligned_access above. - We might widen the access and emulate, but for now - mark an exception and exit the cpu loop. */ - goto stop_the_world; - } - index = tlb_index(cpu, mmu_idx, addr); tlbe = tlb_entry(cpu, mmu_idx, addr); @@ -1824,10 +1810,11 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, if (!tlb_hit(tlb_addr, addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, MMU_DATA_STORE, addr & TARGET_PAGE_MASK)) { - bool ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, - MMU_DATA_STORE, mmu_idx, - false, retaddr); + bool ok = cpu->cc->tcg_ops->tlb_fill_align(cpu, addr, mop, size, + MMU_DATA_STORE, mmu_idx, + false, retaddr); assert(ok); + did_tlb_fill = true; index = tlb_index(cpu, mmu_idx, addr); tlbe = tlb_entry(cpu, mmu_idx, addr); } @@ -1841,8 +1828,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * but addr_read will only be -1 if PAGE_READ was unset. */ if (unlikely(tlbe->addr_read == -1)) { - cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, MMU_DATA_LOAD, - mmu_idx, false, retaddr); + cpu->cc->tcg_ops->tlb_fill_align(cpu, addr, mop, size, MMU_DATA_LOAD, + mmu_idx, false, retaddr); /* * Since we don't support reads and writes to different * addresses, and we do have the proper page loaded for @@ -1850,6 +1837,28 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, */ g_assert_not_reached(); } + + /* Enforce guest required alignment, if not handled by tlb_fill_align. */ + if (!did_tlb_fill) { + int a_bits = memop_alignment_bits(mop); + if (unlikely(a_bits > 0 && (addr & ((1 << a_bits) - 1)))) { + /* ??? Maybe indicate atomic op to cpu_unaligned_access */ + cpu_unaligned_access(cpu, addr, MMU_DATA_STORE, + mmu_idx, retaddr); + } + } + + /* Enforce qemu required alignment. */ + if (unlikely(addr & (size - 1))) { + /* + * We get here if guest alignment was not requested, + * or was not enforced by cpu_unaligned_access above. + * We might widen the access and emulate, but for now + * mark an exception and exit the cpu loop. + */ + goto stop_the_world; + } + /* Collect tlb flags for read. */ tlb_addr |= tlbe->addr_read; From patchwork Sat Oct 5 15:25:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823322 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 490C5154423 for ; Sat, 5 Oct 2024 15:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141962; cv=none; b=fkMhxPuozr63JH/eFvGpnPS5Fp2jebL4FCXU+xkEJrRP/1S/t1Xkg9HzHecObRGCTA3qnsALNyiczN3OWbMe9hcmxldsEmsDJT7zSoQ5o/oD7NXbsbkdw9azoxCQE+Qln6rTU7uAKBkqJosmD+JzDd9ueS1JT98oKs3TFgpwlAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141962; c=relaxed/simple; bh=lMqTSWOZj1IlCEf4v6pbIf89Bz3BR40fXSPmPVcNUi8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BxHLHvW5x3X+pAzIAfFR5MTWMvkt/bFgjyMAdIARZZAWSY2stl34J+aQKomPmqzNS5TdFOVwZcClq+Qxo+Q8NsX//H3BD10Umbi+6vc6uJmzS3YxhYfQG04SBrMykWiFDuZSyUSDLfXqjkeWq92QOqMyaIQJj0NViMw35/3X+RU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=IeQG+SsG; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IeQG+SsG" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-20b90ab6c19so33844895ad.0 for ; Sat, 05 Oct 2024 08:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141960; x=1728746760; darn=vger.kernel.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=MP+WvwE/XecW9wPOVCpjk+gA5jxWiH/v3HQ4ejXK7hQ=; b=IeQG+SsGlzTcChPlge2/THhpp+VqQAF+fQV3q6ewedUsJTNi1CckXsnSBdrlWfVfrO 8E9cI2tatXvNochk3HDfgROwb/ObdD3tWZxYHtw9hZRvLmZYs1hHml81+TYAgoeSrvqe ucVb08BkuYVJEGgYdpbuLbJ9OTFgTyy99xINDuFryFmrm5RbwTUfh/CWIzWKnntDrUDF JgmFI4KybxVITwGyE5MuUulgAejNRXWqFOE04ITSfDj01ouOhrqPlprE1X4IgoupVWtG BCTn/JtugljBMx4k6Ri18TxYI0q/q2vC9cFDDPeUM1QO7HWSVIl83pVTsqJTR/vGzBxm 0qZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141960; x=1728746760; 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=MP+WvwE/XecW9wPOVCpjk+gA5jxWiH/v3HQ4ejXK7hQ=; b=p/Dty5wVOYyfambA7JnOXXFGSNk7MQu6AL8We7oaPNwn2DYN3f1K3QlLZcl1fdyvTJ 6pKPgMrPtKvFNZ8M1Z57UnVPAJ3YGHXlnJDqOb2es7QpuscWfVaYwrfoA9niVrLplRek FUSzULAQvxC1zSVGHLKy63bNgFM3T6cyOQUfq5ZoUr46M2ji94aRiNsc5HjDagdipV6U VbytnggLY4WhKRtgANZAEV1YH2LesMvi3TSzaVY+LJq0hEAxwyRTP/Lou8Oq8IwYgpQz k+C7AVtyqNVyAy37nmXIqQQ4dGn8hbVXjR/uV6HUOR/x5qlWM2I0+4LZjUOEQYTMMqFw n7eQ== X-Forwarded-Encrypted: i=1; AJvYcCXhHWegj5r73MzJ2J4Bbm+WqiHXX1qrlFwftw/hOUOZYV2IhqD/kUB3zKFkcEp5+5Q4/j9ZxJbUxG7wJLo=@vger.kernel.org X-Gm-Message-State: AOJu0Yya5K+7V0AlUrI93K1Wvd8iUKKl0MgAsfNN81gbyBYkwE5q/Jdi kbGfaPlINr2MbHxonSChqrktplPVWpBOu9EMosBvLt3ToPyripM3Og/ndeAUmrY= X-Google-Smtp-Source: AGHT+IESYzC42ts/+MgAFBURTMzI6DPqe+lqay1qM2V34nvaOe/CY71VOZQTw0rCb6RzMXOSgxY+yw== X-Received: by 2002:a17:902:db02:b0:20b:ba72:37c with SMTP id d9443c01a7336-20bfea542c6mr100209775ad.48.1728141960541; Sat, 05 Oct 2024 08:26:00 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 08/20] target/hppa: Add MemOp argument to hppa_get_physical_address Date: Sat, 5 Oct 2024 08:25:39 -0700 Message-ID: <20241005152551.307923-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Just add the argument, unused at this point. Zero is the safe do-nothing value for all callers. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/hppa/cpu.h | 2 +- target/hppa/int_helper.c | 2 +- target/hppa/mem_helper.c | 9 +++++---- target/hppa/op_helper.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index f4e051f176..526855f982 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -369,7 +369,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, - int type, hwaddr *pphys, int *pprot); + int type, MemOp mop, hwaddr *pphys, int *pprot); void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 391f32f27d..58695def82 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -167,7 +167,7 @@ void hppa_cpu_do_interrupt(CPUState *cs) vaddr = hppa_form_gva_psw(old_psw, env->iasq_f, vaddr); t = hppa_get_physical_address(env, vaddr, MMU_KERNEL_IDX, - 0, &paddr, &prot); + 0, 0, &paddr, &prot); if (t >= 0) { /* We can't re-load the instruction. */ env->cr[CR_IIR] = 0; diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index b984f730aa..a386c80fa4 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -197,7 +197,7 @@ static int match_prot_id64(CPUHPPAState *env, uint32_t access_id) } int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, - int type, hwaddr *pphys, int *pprot) + int type, MemOp mop, hwaddr *pphys, int *pprot) { hwaddr phys; int prot, r_prot, w_prot, x_prot, priv; @@ -340,7 +340,7 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) mmu_idx = (cpu->env.psw & PSW_D ? MMU_KERNEL_IDX : cpu->env.psw & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX); - excp = hppa_get_physical_address(&cpu->env, addr, mmu_idx, 0, + excp = hppa_get_physical_address(&cpu->env, addr, mmu_idx, 0, 0, &phys, &prot); /* Since we're translating for debugging, the only error that is a @@ -438,7 +438,8 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, break; } - excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, &phys, &prot); + excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, 0, + &phys, &prot); if (unlikely(excp >= 0)) { if (probe) { return false; @@ -678,7 +679,7 @@ target_ulong HELPER(lpa)(CPUHPPAState *env, target_ulong addr) hwaddr phys; int prot, excp; - excp = hppa_get_physical_address(env, addr, MMU_KERNEL_IDX, 0, + excp = hppa_get_physical_address(env, addr, MMU_KERNEL_IDX, 0, 0, &phys, &prot); if (excp >= 0) { if (excp == EXCP_DTLB_MISS) { diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 7f79196fff..744325969f 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -334,7 +334,7 @@ target_ulong HELPER(probe)(CPUHPPAState *env, target_ulong addr, } mmu_idx = PRIV_P_TO_MMU_IDX(level, env->psw & PSW_P); - excp = hppa_get_physical_address(env, addr, mmu_idx, 0, &phys, &prot); + excp = hppa_get_physical_address(env, addr, mmu_idx, 0, 0, &phys, &prot); if (excp >= 0) { cpu_restore_state(env_cpu(env), GETPC()); hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx)); From patchwork Sat Oct 5 15:25:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823323 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2986B1EB36 for ; Sat, 5 Oct 2024 15:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141963; cv=none; b=SeG8mWKP7l3zkotrME/zIt147k3D4285/gnbEjRCijK+jFqYU2de/eUgz6aSQTq++3WQmE5l3jESDmDUqdRw4+GReRPLN+B0712WcNxoi0pxnRuLYODel5dMEbbDUQnF48cGnXa9a0pnrxJaxDrPef1guhYi4eVuierfSrZMCAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141963; c=relaxed/simple; bh=tZoCwtIK/p1jJzOfgZpJrtMvDCOC/SNFglCoA1ddJgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VIK6oJ4YArRji+1ExL6u5U394aSCYop7ismNOe6GcO35Mmo9kmEq5KYq2CFFrTCOTqz1r6wyLo+uSwQxnpIqX3EmKZEZmGnYZEn4z9HJJc9i0JzJ/CYVhEHCvq8NLDFXZ7m9VYjc/p43r0WKLbhmKXgD3MO9c6kYBW97/MyJA3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FX4XwuA9; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FX4XwuA9" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20bb39d97d1so27185145ad.2 for ; Sat, 05 Oct 2024 08:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141961; x=1728746761; darn=vger.kernel.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=/wa2JC5GTiuZOa9FUt+c/E5R/4D7wBSs90VoPwelenc=; b=FX4XwuA9aQxSKoFeeWCruGBoej3riyg39adjGhg065F4JxCwZgpES/l3FZ69Z48+fQ u8dngJQD16ZwlIuztCJWNe0fng4LZ+oVEfbvhCY6vwA5kj1gbEsvrjeZVlh/8iuDv5RM 3GsNbb3YcmHzqKU80RyUz+RKEy02A9Vzg9geu2wd1+MkC7reyChkLcp5dX+1ErGU6gw5 /Wy8Vebs+PYqUuiYQOOIP2z7E68TJ5jvJZebQ9HjJ4fwRWCNQLFA0MSXCeeJuulYJmWL GN87qIDYV4I5PrszC7wYYdh6hp6xgt2rIErT/aukuWDX7mYvSBHyYcNGn1l1zDKyPoEv lstA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141961; x=1728746761; 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=/wa2JC5GTiuZOa9FUt+c/E5R/4D7wBSs90VoPwelenc=; b=Hh6q+PKWF4YStkEfqLn0C//3PVsDqUyQj7kLkZomKPk5BGjejIFtEhDPBRtpCGyAVq /WjUbYTaxT1JIT4ofhbxFIl7NonyUH1PwMaewpSgFV9k9/vEKXRKfl/CYYZ0Y2b/qiqT /+GZmeb/yGcLmYuuwGOtMJX1vykNqEa5+zFEnv8J1VyDhjOckRduvcAvRrMSTfXKlL2q u4lfLz03mR328huLfNJJERbo5YqLPZYCBGJhobw4xBTVlRTlUgKLnmuQ2fU3OLSYQu5T jRelvRHJtgNQfawNJXuTsqhcqurB+aZ12kHU9srbhTOiBuBZnL4AgolOGs9ipTKXzRgU 4KGw== X-Forwarded-Encrypted: i=1; AJvYcCVwrj0pPCDw10Gi8bYLV6cXkAD+YctG/1UGaKfXD8eWSsgrfb15drcsU8ZnLEa/GwkYQhOMzzvxrTR5YfU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywx9Yb/rq1TOWIBrV/dLTakJcX9MFMvK93mysbysYEVaYYdwhSj 6pM6K3HCefke9HL6tjwi6mv1h6mc4TwMuud1QnBbqeVpYB2puEFyghExw+1AG5M= X-Google-Smtp-Source: AGHT+IG91WPfsC5D7LXHeMJAPorkuse9kNn6CykSYZIeBAI70lXeJDkn5eW9lfVj7aitw+VRpPphGg== X-Received: by 2002:a17:902:e887:b0:20b:8036:f77f with SMTP id d9443c01a7336-20bff1a9178mr88727005ad.46.1728141961604; Sat, 05 Oct 2024 08:26:01 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 09/20] target/hppa: Perform access rights before protection id check Date: Sat, 5 Oct 2024 08:25:40 -0700 Message-ID: <20241005152551.307923-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In Chapter 5, Interruptions, the group 3 exceptions lists "Data memory access rights trap" in priority order ahead of "Data memory protection ID trap". Swap these checks in hppa_get_physical_address. Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index a386c80fa4..f027c494e2 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -267,6 +267,12 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, goto egress; } + if (unlikely(!(prot & type))) { + /* Not allowed -- Inst/Data Memory Access Rights Fault. */ + ret = (type & PAGE_EXEC) ? EXCP_IMP : EXCP_DMAR; + goto egress; + } + /* access_id == 0 means public page and no check is performed */ if (ent->access_id && MMU_IDX_TO_P(mmu_idx)) { int access_prot = (hppa_is_pa20(env) @@ -281,12 +287,6 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, prot &= access_prot; } - if (unlikely(!(prot & type))) { - /* Not allowed -- Inst/Data Memory Access Rights Fault. */ - ret = (type & PAGE_EXEC) ? EXCP_IMP : EXCP_DMAR; - goto egress; - } - /* * In priority order, check for conditions which raise faults. * Remove PROT bits that cover the condition we want to check, From patchwork Sat Oct 5 15:25:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823324 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC4415383C for ; Sat, 5 Oct 2024 15:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141964; cv=none; b=X7KUb/LjYU00rj1CdBhrTpbwzHvwFvoItTKfxuQhGzFGNKjBCzZAh03onUECswaRYqDvQiHdix+exla7NrXUKJYCp3JR4SWx6o4+FFdJ4SSPdOXzXHQ323LxbIaBcwYVEakXB63YNOFOZjaQJLORs/zmLYWABlJPPFGmicZGC+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141964; c=relaxed/simple; bh=sTfOjnd7WOnuX+x1S4o3BYX1tyPFXVNWkYKKV6kIQa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VTIaO+9aw+UKAGiQ4ec+gqjTal045++mD/iRVptfUXtbp6var2pHY8mecxGnXS+y779TVQdgYTSMrkJhkLONgSCXvpaUh5dL7m86WLSQ6+JV7re9Mkxf+zQeV7d7tQZgPMxIqpiA2zrl7ovY5ZPX9mJQdE4T2WOsXmJn+DTLya8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Y/SMSfzs; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Y/SMSfzs" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20b9b35c7c7so21873195ad.1 for ; Sat, 05 Oct 2024 08:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141963; x=1728746763; darn=vger.kernel.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=posPbKSzdb+ffX+WhfgYFaW0pAyKjx4IZlbzVQLaTuc=; b=Y/SMSfzsEtThObkqK0j+EJt8kpjKHFc4OYufX1y9NDqlMPMut5/d7NbIrp89fCzF4Y LpoOOMiGU9T9N8/jxSh44UNBGKhOIBCpCdy+qRNU1ZfzUFpK+E4jDefD+Cv8YsUrmbOR vUfdY5pvIVXu3d0w47ZYJSMYoUNsIS7ptYBHW1G4yVeM+Zv+nhSUe4Mzja4b3AGG9W7V f0bsiUB8dcl4q/MdKVqftDC+sL1IF3E9Xpyc4QvxiNIk9GKrF4DQn86DX/SaS54aPK6d P+pBa91fqm7ghnk017ciK21EzUZOF3uGKQXpRZUKcnwTqzYAIko84PNfMwncoNULkG2Q YB6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141963; x=1728746763; 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=posPbKSzdb+ffX+WhfgYFaW0pAyKjx4IZlbzVQLaTuc=; b=vhGPSCupzLtRj8H9F9oI8X33qDz0zdAqo/BwT4sHrGPj5Yi/u8BAwYHBWsBAns4Bdu DHRffrRP1lBEkZoKQp2WDynkyQ+YZzGVCH8JRkCpNKEgpb0hV8ExUwWXQhJujWVTa1tZ /aUupvxMe4XVJzQaDFWn9Uvct6rI3yLR931X7JPj65FgcCTpU0r6M+AQBuXpzgdJYOyX rIOLZwwMmx7z7iRMgVE3ttT6vVa8i2SGA0duPrAPTEHuesCVDUW1AwYBCxqfknm22bIy b/r3ZmyCrQpXwO3ENrCaC823pegiTSkqDDms4rG/+QlZQZp5r3U8IucgA/oDkJ4pNkmN X45w== X-Forwarded-Encrypted: i=1; AJvYcCVFaCkbyYPyVodRY4/Ta+Lqdbt6rZPlh2wBIY/vSG6MjjoEnwx5MBiCkwt2mtwPwSXSFaONMoW+TR4NJLQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxLMutfS5XOAdlQeA3WS72bq0wK4WtEJehl4KIeqOauhSQ+FP49 GtjwJSh71hzF+0JqWTiKm9xI4+ia48fw7TNxtTOaS8FoHOQED9XEsscjAwAIAXw= X-Google-Smtp-Source: AGHT+IHBX41nPwo6covULM+vMbiWEGGIhbj1kTBPJ81VMsZIIlt+W/XQXaPT0SdsNmz4Xr77GlztTw== X-Received: by 2002:a17:902:d2cf:b0:20b:502f:8c2e with SMTP id d9443c01a7336-20bfee333acmr92469555ad.51.1728141962599; Sat, 05 Oct 2024 08:26:02 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 10/20] target/hppa: Fix priority of T, D, and B page faults Date: Sat, 5 Oct 2024 08:25:41 -0700 Message-ID: <20241005152551.307923-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop the 'else' so that ret is overridden with the highest priority fault. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/hppa/mem_helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index f027c494e2..f71cedd7a9 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -288,7 +288,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, } /* - * In priority order, check for conditions which raise faults. + * In reverse priority order, check for conditions which raise faults. * Remove PROT bits that cover the condition we want to check, * so that the resulting PROT will force a re-check of the * architectural TLB entry for the next access. @@ -299,13 +299,15 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, /* The T bit is set -- Page Reference Fault. */ ret = EXCP_PAGE_REF; } - } else if (!ent->d) { + } + if (unlikely(!ent->d)) { prot &= PAGE_READ | PAGE_EXEC; if (type & PAGE_WRITE) { /* The D bit is not set -- TLB Dirty Bit Fault. */ ret = EXCP_TLB_DIRTY; } - } else if (unlikely(ent->b)) { + } + if (unlikely(ent->b)) { prot &= PAGE_READ | PAGE_EXEC; if (type & PAGE_WRITE) { /* From patchwork Sat Oct 5 15:25:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823325 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AC401C6A3 for ; Sat, 5 Oct 2024 15:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141965; cv=none; b=ZJ3iZsBinDf+1nvQ0sLvYR27yRB+h3bWLgbY/mSXg0Mu2+jn2D+dVTAVFDkMBJl1e71i3aT4oT4sS45imqUAdvSSD439vnrTXeItRVOpdKqzLRJQKhPbwyHBISoGoiFxU+ntlMz2935GxGLUh2zevOxXSzDzr6/WwNYh7lzeTHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141965; c=relaxed/simple; bh=4iaK0QoQiOhshJacorWqZlodkQnPRyOf/R/YyIYfv1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=onDaNV1n7rUvPq97tfSdBOOOIC6BLEOhQhhZIAfiE85GCK9ieMPaoRIq22ZY8CtO1RMa/KyVUDL/VHA+O7MxrPvsvkCQ6qP1iGkpWmSh6c6jsqpOsmw52L7M6ImIsfce+cKsJCnHZdu5w/fpvr6bG6Bqbf6i9zyxZgbFdmq8fFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PXZoLuuN; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PXZoLuuN" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20b64584fd4so30733875ad.1 for ; Sat, 05 Oct 2024 08:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141963; x=1728746763; darn=vger.kernel.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=TZFSB9ZUy/VXACo96L3HUXARpyVU9ywq9XNxX+p9inM=; b=PXZoLuuN63NeNe//PKH4u1pfWOvgS4Vyj0gu2CJ9AuPRnwSTR2MKXOO7CD8PM+oszh eK0gQHs12KN+Brwyj+C8BW4iz8hqZRNbVRsbzqkJAdzfQhecD1GB+zfjll4nSaq0670p MKgXPmPuTB5ABkwbUyXW/qDMtoXaGYC8rNHyK+0hD3F44fS37vYGu4kJQ01BGAnmqSCV 9OufzmTOv4o4d41Fg+coKlB3519R7EAVGnbdif/58830N4iTiMfXDagwu+JxLMbvQAri g9KvQnhiqQZr7uSFMIqXICMqCz7KsCBOo6CwUUUtNicghKDh7B4mGb1EAu5XUr/qWcDh 3AdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141963; x=1728746763; 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=TZFSB9ZUy/VXACo96L3HUXARpyVU9ywq9XNxX+p9inM=; b=lcl+69hmZcTrNs/Z78+Gwojh9ihJgrQq2TZ+TYChryhzoP6Co1I7nhzBOuUQlNUeup 37Pl1VtOXPprFOGiintGruKWt7Z3mc2vLt0vm5i5ZGxbGPytvOyQNAeX9p40QFXjSN3y tSMy4yyzZBBAEjw9ReqHsbtaqlB54jHRLpt1Gg+XU8xBKPU0XPlNPCZHrkeU9mYpph6t Otat1BWL8T9enmlk22XQVK2Wqyeg+2ax3q5oVt9eiCWjUsKTBs9cC5TKaFkHTiikT2/V U1hxVDNZImdIzZ2bTbcjbpnaNKoKQCooxmYffexHbZFMDfirCyYiwrSDyJ8pE+BkpMXV L7Hw== X-Forwarded-Encrypted: i=1; AJvYcCWrBV0Zg9l3yOjrNkPYN43ybUXCSNR6pDhP1a6KT1jMWDoMJQRopRNnC8PuehwjKss6rdKT9T2uiICB7rw=@vger.kernel.org X-Gm-Message-State: AOJu0YwC+/a4ODn2o1ZcXWjWU+yasWd/W2IzibtsnWFi6qPWBM9ESwoT 1dLkRgpK8n4tuCJL6Hfka0wOvvh1AuraPFZD8HBhsAP48FlMNh6hwQMRQmgOiRo= X-Google-Smtp-Source: AGHT+IHoHMOdQJhz/hk6oo5QEC16Z8Yklqh5lMZB6Txlb+2L2pMHFtFjRuBs6OrzX6SPGfE0OUkqtQ== X-Received: by 2002:a17:902:f788:b0:20b:8ed8:9c74 with SMTP id d9443c01a7336-20bff1cb9d3mr97600185ad.49.1728141963574; Sat, 05 Oct 2024 08:26:03 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 11/20] target/hppa: Handle alignment faults in hppa_get_physical_address Date: Sat, 5 Oct 2024 08:25:42 -0700 Message-ID: <20241005152551.307923-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In Chapter 5, Interruptions, the group 3 exceptions lists "Unaligned data reference trap" has higher priority than "Data memory break trap". Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index f71cedd7a9..d38054da8a 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -221,7 +221,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, g_assert_not_reached(); } prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - goto egress; + goto egress_align; } /* Find a valid tlb entry that matches the virtual address. */ @@ -323,6 +323,11 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, } } + egress_align: + if (addr & ((1u << memop_alignment_bits(mop)) - 1)) { + ret = EXCP_UNALIGN; + } + egress: *pphys = phys; *pprot = prot; From patchwork Sat Oct 5 15:25:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823326 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F073615383C for ; Sat, 5 Oct 2024 15:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141966; cv=none; b=tWeleh5opMmzOcq/ljAsN2sv4N6UNmueV03x7huSMiOcs6fu/dcIbjM1TObIuQbjdPnPp2mgbqR2JnxB1h92L76z9C9QBuQu1ZlnOlqUjzjYPZZKp+4fQCE7cDCIyF9Ycc8+y6sFaOq/WgDO56R31PA4EAYrzu9+ydPeYEB7Y7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141966; c=relaxed/simple; bh=4Y9YWp6EM7aAkdmftt8JKSZpOs1BvVvy02XzjMP1/6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LcAfn9e3B/sZvofP+L26uVDcRjrYW9DGAtS3RlHYd2CWd/DvXxWMRyXwubt2LnxBkr/dTUoIvTdtgNFzxMaPCWDMuPl1Y0TOZuQZZ0+QAHmVZSbV63RMUZztFDQ8cUPxlrwD1Z988oymqzFD7BHEx9DNwFVbqH6C+i+SsQmI58k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QyI6ZrGY; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QyI6ZrGY" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b90984971so32651135ad.3 for ; Sat, 05 Oct 2024 08:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141964; x=1728746764; darn=vger.kernel.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=Rc7m2CC+o/vfg9459Vx/ro/giFzSXc14VGjLvy+03yM=; b=QyI6ZrGYye8j0jgG2wNkeWu3g/xYr44/RnY48GmZiUbIpphVl4fLjXtedL7HWY8dta 3XPCQI+efqgztUmFEL76g6tJiJjAHodtZwDVMQzh837HXI7Chz79xU73Q0NyqUWLKGUh h+ie8HSMe+FAVJHfWerukcQSZa9jGwQc0qaTTU6XKeenefZ6EdDuMg1MijI5Hl0P3Hx1 3C9bknhfw7VETNYyt7gpsBzeYjSH5u5BULVkqcDEp3O5WCOgSHoPFYT2QlPgVKcyGu+s 7JD/HtoE1qvzP46kPqkz0CB8C5s2MyRSN8YqlwSKvxfesHPPWhIoYlsxU/5kTnQp/RCw GCjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141964; x=1728746764; 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=Rc7m2CC+o/vfg9459Vx/ro/giFzSXc14VGjLvy+03yM=; b=RDTyRjZhW38qQkPzSnwOm0hJkLubwYf7OBj/pcX6lpLGfRU0AYN7K0Wyj2zf8MRJan q1Fw3r4Xj4ZcB4qLhIHqsHHk0ZMRY8EB/2ZgoDVqjIAe8iBvMRgGt797R0sGoCJa+Hfu /XWGlhtkfwVWMnQHJkDmvHMPfvaiG6mOktVFfiaARZ7lwnOsXFC5na+6ecAStX25sUP1 yQGZq6B2k0/ibzAaj0EiDNz/BPAU74SGdqMY1ClrQOK6ZLzvJsZ2siKSMoD7lpLj/XGi BmZf0NRNw1sFLQbycIMr8YOnK1mVVsXwHL828z/YiUnoMGswbn98rIcyKUQrDPdnXDp7 nr8A== X-Forwarded-Encrypted: i=1; AJvYcCUUPsihh0s9Bj5aExgW3LnfAtYPBcEcOX2bwldm+ymbeOsVRQj0ljDlSlw9XHm6j/fcXrBBPWxnFq9a74M=@vger.kernel.org X-Gm-Message-State: AOJu0YwZy17t8n6v4/Nbmkj5cCClGoVHVAh3b2r2W66npYAFNS8GCdAB LzITPAQ266IwpQzJBvt0qWkmMvGUNw2MWdUkrG30rUF46KLGbi/hgeIkxdr6bTY= X-Google-Smtp-Source: AGHT+IEvLU9GLG2DeoI40muI2sipayJdhU5jBLMkBCCO1UbeJJe53a/eQXNvSkSI8ZhFOYTqxOfpOg== X-Received: by 2002:a17:902:db04:b0:205:709e:1949 with SMTP id d9443c01a7336-20bff04dd11mr92195455ad.57.1728141964403; Sat, 05 Oct 2024 08:26:04 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 12/20] target/hppa: Add hppa_cpu_tlb_fill_align Date: Sat, 5 Oct 2024 08:25:43 -0700 Message-ID: <20241005152551.307923-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fill in the tlb_fill_align hook, so that we can recognize alignment exceptions in the correct priority order. Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 3 +++ target/hppa/cpu.c | 2 +- target/hppa/mem_helper.c | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 526855f982..c0567ce0ab 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -366,6 +366,9 @@ void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled); bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +bool hppa_cpu_tlb_fill_align(CPUState *cs, vaddr address, MemOp mop, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 3b6c325e09..768abc6e5d 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -226,7 +226,7 @@ static const TCGCPUOps hppa_tcg_ops = { .restore_state_to_opc = hppa_restore_state_to_opc, #ifndef CONFIG_USER_ONLY - .tlb_fill_align = tlb_fill_align_first, + .tlb_fill_align = hppa_cpu_tlb_fill_align, .tlb_fill = hppa_cpu_tlb_fill, .cpu_exec_interrupt = hppa_cpu_exec_interrupt, .cpu_exec_halt = hppa_cpu_has_work, diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index d38054da8a..35e9170bf3 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -424,9 +424,9 @@ void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, } } -bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, - MMUAccessType type, int mmu_idx, - bool probe, uintptr_t retaddr) +bool hppa_cpu_tlb_fill_align(CPUState *cs, vaddr addr, MemOp mop, int size, + MMUAccessType type, int mmu_idx, + bool probe, uintptr_t retaddr) { HPPACPU *cpu = HPPA_CPU(cs); CPUHPPAState *env = &cpu->env; @@ -445,7 +445,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, break; } - excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, 0, + excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, mop, &phys, &prot); if (unlikely(excp >= 0)) { if (probe) { @@ -473,6 +473,14 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, return true; } +bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, + MMUAccessType type, int mmu_idx, + bool probe, uintptr_t retaddr) +{ + return hppa_cpu_tlb_fill_align(cs, addr, 0, size, type, + mmu_idx, probe, retaddr); +} + /* Insert (Insn/Data) TLB Address. Note this is PA 1.1 only. */ void HELPER(itlba_pa11)(CPUHPPAState *env, target_ulong addr, target_ulong reg) { From patchwork Sat Oct 5 15:25:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823327 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0881D1C6A3 for ; Sat, 5 Oct 2024 15:26:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141967; cv=none; b=IrJfBQCZK3O5PRbwAn8LApR6SGz+N4/5ok8YRPcTNY1YUye2t4UEzNZog5TAryaNj0nqnhFf4vU0G9qYYmWynMruPm661FrFfvYLoEEXmKuDlVnym4WlKd6s63KBoNrlNlXlc47rsxQcfCFfCHTz50oGai1vnMPF0xn4ivwrRG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141967; c=relaxed/simple; bh=vDk3HNbU7V0mlRGB4QGw0XzPVHWLM0iY2xxG+t37CEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IcYo8huCaHwhrflK88za1K/5v5IVL83FcT4W8GcbghUrpDtxa/i/jIJSU+GKSZbs/XegZAtUQBbxomHzhAcfjffeP6n185VaOVuV9A6KamvdCacI4ZeSYvhu59kRAGXg2GJNwbn1YnmTcScTRmawSnI+x4sznntqDUTxuWklJm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=MtY69yoo; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MtY69yoo" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20ba9f3824fso24155385ad.0 for ; Sat, 05 Oct 2024 08:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141965; x=1728746765; darn=vger.kernel.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=E1uh5v8Er5HwrssIP/tcmhd1DyyVCAW+cpRhBaU0frQ=; b=MtY69yoo5RGU1NOISFmMqpPDiZH08qggUzR0H9YBrkiXIlEbXwHgmcfT6Z3IiyU24A kA7/uqqI8GLWuaYrw8g95Hkdd8vavHpYleO5cXM7UwyIxO6AXQ08MoAQe/UvlyHV6mdN NfjH3qbEJkW3Jc+kgq91J13vyS/XpaM3Hmado+UM/gcsKDP2HUQpoU7cPbMuC17w4OrS 6Aj/K0E2OHXGquWKSm7dhdGFhCa7Sq/Fxt3dzEs7QyuYv35WSlclMLnq7eJOGowb02Lj inBiMJsxpVy3wyotZQLs1dOvdPYadR61sIXlFvLQYB4WveWCNW5EjZlSsMbSJWgFnFXd 94MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141965; x=1728746765; 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=E1uh5v8Er5HwrssIP/tcmhd1DyyVCAW+cpRhBaU0frQ=; b=Y4DFN1ozlowYfom6QmkGcLXUXF+Q29gEE5yLagu5qtaIB8BotjbwhLceKe6NiuGpzl P6ygJKj8UZCsl5qaqcbx9R+d+mOsjm2Kj/6bXECpKkw8Y5J9ze6HXp5A24Uyw9AukiyT XK5NoDcPGv1n/DHGzx5ElwtBaZgUFBhWBlh3W/WQjHKaUsg/IFftSXznXpnz1+rD/0nz yoi3rxvTGqAwmhG1GNZATdpR0HtEANXHjfrFaXGZLC0GGvJizifEGIQl1tovZamWBlWR qY6p2d+kR3AHVWmX/i8Cjylie2zQTnffEMs0OpdYY2hft3Ys3y5rUjone+WVxQ8W9zLz a2iA== X-Forwarded-Encrypted: i=1; AJvYcCWK3eX3ytStt7GhD3I1+f3todQn2zdpH8lz9xRpaX/s0pBd0IFlU963Vsvfk2VLdmXrXGewlrzvnY43khU=@vger.kernel.org X-Gm-Message-State: AOJu0YxUEZTZXOWD1EHMOXeLZX5GK5Q80/OBO3uSjFSHPLocJ8zhhDKz Shj5wtCAKVPXbAI5uV04dD+yRSWMH6a7VofcJChtk6KbfAMi1yTQi78/8dt1tOQ= X-Google-Smtp-Source: AGHT+IHcBazs1KoKTrZ3DdroHH04DM/SKr28uFu00SI0srezv50JszdEiHHXeKd4Hjq+Y6+ipXC1jw== X-Received: by 2002:a17:903:2307:b0:20b:9088:6545 with SMTP id d9443c01a7336-20bfe95dbcfmr96932395ad.46.1728141965422; Sat, 05 Oct 2024 08:26:05 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 13/20] target/arm: Pass MemOp to get_phys_addr Date: Sat, 5 Oct 2024 08:25:44 -0700 Message-ID: <20241005152551.307923-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/internals.h | 3 ++- target/arm/ptw.c | 2 +- target/arm/tcg/m_helper.c | 8 ++++---- target/arm/tcg/tlb_helper.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 1e5da81ce9..2b16579fa5 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1432,6 +1432,7 @@ typedef struct GetPhysAddrResult { * @env: CPUARMState * @address: virtual address to get physical address for * @access_type: 0 for read, 1 for write, 2 for execute + * @memop: memory operation feeding this access, or 0 for none * @mmu_idx: MMU index indicating required translation regime * @result: set on translation success. * @fi: set to fault info if the translation fails @@ -1450,7 +1451,7 @@ typedef struct GetPhysAddrResult { * value. */ bool get_phys_addr(CPUARMState *env, vaddr address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) __attribute__((nonnull)); diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 659855133c..373095a339 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3572,7 +3572,7 @@ bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, } bool get_phys_addr(CPUARMState *env, vaddr address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { S1Translate ptw = { diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 23d7f73035..f7354f3c6e 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -222,7 +222,7 @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, int exc; bool exc_secure; - if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_DATA_STORE, 0, mmu_idx, &res, &fi)) { /* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { if (mode == STACK_LAZYFP) { @@ -311,7 +311,7 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr, bool exc_secure; uint32_t value; - if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_DATA_LOAD, 0, mmu_idx, &res, &fi)) { /* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { qemu_log_mask(CPU_LOG_INT, @@ -2009,7 +2009,7 @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool secure, "...really SecureFault with SFSR.INVEP\n"); return false; } - if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_INST_FETCH, 0, mmu_idx, &res, &fi)) { /* the MPU lookup failed */ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure); @@ -2045,7 +2045,7 @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx, ARMMMUFaultInfo fi = {}; uint32_t value; - if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_DATA_LOAD, 0, mmu_idx, &res, &fi)) { /* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { qemu_log_mask(CPU_LOG_INT, diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index 885bf4ec14..1d8b7bcaa2 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -344,7 +344,7 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, * return false. Otherwise populate fsr with ARM DFSR/IFSR fault * register format, and signal the fault. */ - ret = get_phys_addr(&cpu->env, address, access_type, + ret = get_phys_addr(&cpu->env, address, access_type, 0, core_to_arm_mmu_idx(&cpu->env, mmu_idx), &res, fi); if (likely(!ret)) { From patchwork Sat Oct 5 15:25:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823328 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0882915383C for ; Sat, 5 Oct 2024 15:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141968; cv=none; b=vF9Tx7Yauaxdp0JJO5MjL4vbag3kvpNX5cMwH8x6hlbgjhOu2oD8+ADTvqsxopuo2l86q/UuXvO5xDd3GSEqt8IqkZEN8bne5pEyzgEzPMpJfkEIG65Ov90agNpXQ/VATD7HtBeFa837ASDdSUhGgLXhBTH5HrUeuh9yTY0i4Rk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141968; c=relaxed/simple; bh=0LcUXggN44y26UL2csydkFcmlkLrDThLrVZVjfPCMMg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YEUr/bmBOCZvh1pfVQ1weowePz8+M2C7mpsr2bYpASVy1P3BO7LesXGfB5JyHua2OKI1g16umBn9KBXiKA0oQjmQQ/ty84cx31LuLL6cT2IKmgqKU3knOXV7qLP79Y5r5PIQNpzSpE/iID9UlDAsyXIPY47QeGvTppMF6U4Ycys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Oq3NJcHp; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Oq3NJcHp" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20b84bfbdfcso27420325ad.0 for ; Sat, 05 Oct 2024 08:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141966; x=1728746766; darn=vger.kernel.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=or+46uGq1e2/GbDMKkBXfTr+x8kd8hih+f1GC2rPQFE=; b=Oq3NJcHpi4shwRvAI6/yWHtj5n6KBd1MNy8zbLVik/QOqmpPaxF9te3ZIwXgr+gxnu TFhhwJVieWyYjbxMzgy7Rsd3lVfC2PjrsqDKHWYcnYKiDbibfe5MgriazE2RgY+n5k8f 0a1fBOyyvhQkHQ5st6YoSlQifQA4gxwc3Ifnt4Fy71KgthUuv3UgPnwVxDoBIZihqHrd lBoXHXs4yBc3jgG9si+5NZ9HIMcz/uD1EQP2sDlx2N6m6OJJ4sH1zK2I5TSjrrzeR2Ws +udGUUo0vCUArF5pwicTtJoVnoYci3VAojl7pFn9lipEWjXvQnRKDm8SxwZWEaITh7PQ Yc5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141966; x=1728746766; 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=or+46uGq1e2/GbDMKkBXfTr+x8kd8hih+f1GC2rPQFE=; b=LeAgMVel3fAGronIcnNPXgoRHQ0wLgIQmP4zPrjbuWBVB6529j+evnv6u7UBDJD8Zk 4RhNtmor3ZZgaOpbdJe1e4oI841wHgUMnvqi49+/PcRwvaqdKbnov8OnSpxViVA/Cs0v B4kifOPaqNagSNLK+J3vckrj0f24ytQ6TmfyJvXcF2dLsBj77bdbxvmIHqXRqd3dijrR EXVFkcggAXW82P6mWmXQGB3Oaa115XP7HpuyQ4fdZ2cRKyIYbC1mF7SknXQCRszeQe/Q G8+J0uSasCQy8iWoCaXKSkzJzEFyKQC0uKd97xiz1u2L/q66xa3EQo+5B9BBrRN/v81Z F3ww== X-Forwarded-Encrypted: i=1; AJvYcCX2uV+jY083XoYy5IOiPu5ILacSZbLdjm5WNBFS7WIrvjo955iRNL3rpKnb22mDiLiqlwBwUtpvFAY2pe8=@vger.kernel.org X-Gm-Message-State: AOJu0YwVociKvYi3x6LuVvRtrIHv/eLV1L5//AG+mrOUnPkt/pr4Phc5 bT8Y4mu58h1I1M/h+6oMgvQV62hce9q2cWdUFWAhEasgF+KVZYqdzm2vGe2qncc= X-Google-Smtp-Source: AGHT+IEdkuFzCvH96y6A82QUTiEIn2YBst+4kAUKQBDmS2IlhhIPoF71jwAfADtzZPGVJyjEo7r1sw== X-Received: by 2002:a17:902:e887:b0:20b:9365:e6ea with SMTP id d9443c01a7336-20bff393be4mr111588295ad.10.1728141966447; Sat, 05 Oct 2024 08:26:06 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 14/20] target/arm: Pass MemOp to get_phys_addr_with_space_nogpc Date: Sat, 5 Oct 2024 08:25:45 -0700 Message-ID: <20241005152551.307923-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/internals.h | 3 ++- target/arm/helper.c | 4 ++-- target/arm/ptw.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 2b16579fa5..a6088d551c 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1461,6 +1461,7 @@ bool get_phys_addr(CPUARMState *env, vaddr address, * @env: CPUARMState * @address: virtual address to get physical address for * @access_type: 0 for read, 1 for write, 2 for execute + * @memop: memory operation feeding this access, or 0 for none * @mmu_idx: MMU index indicating required translation regime * @space: security space for the access * @result: set on translation success. @@ -1470,7 +1471,7 @@ bool get_phys_addr(CPUARMState *env, vaddr address, * a Granule Protection Check on the resulting address. */ bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, ARMSecuritySpace space, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) diff --git a/target/arm/helper.c b/target/arm/helper.c index 3f77b40734..f2f329e00a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3602,8 +3602,8 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, * I_MXTJT: Granule protection checks are not performed on the final address * of a successful translation. */ - ret = get_phys_addr_with_space_nogpc(env, value, access_type, mmu_idx, ss, - &res, &fi); + ret = get_phys_addr_with_space_nogpc(env, value, access_type, 0, + mmu_idx, ss, &res, &fi); /* * ATS operations only do S1 or S1+S2 translations, so we never diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 373095a339..9af86da597 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3559,7 +3559,7 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, } bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, ARMSecuritySpace space, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) From patchwork Sat Oct 5 15:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823329 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEA701C6A3 for ; Sat, 5 Oct 2024 15:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141969; cv=none; b=nmkYK2VXrfVv60xDCFE7c3cDKAUbQ7kSHxY3XUxRCjpfu9zhmGw1OHzuIuyBDuE70kgX9uEDV5ooMsGC01NGCEECk1WrRatxaVG5agGtgr6YXZJnmc35qPx5lQMleYvwQr+pXIli1YMRmGWxmkfXD0ivVjdoatc51oJJ84Rn9OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141969; c=relaxed/simple; bh=XTzfK06oaFA2G+iVog17UM/vpH9ZZI8haEnAh7kVvHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KbwIdqLaL0Io/lDjjwji3Jv+MO1Up7ZRfSl+ehNs1ocsYIDHNenBzVBvt3yR1zWRJNehQd8gNhfWN19NDmrigHMQ6nVxED78eA9pbgJgGRqI5U7Wf8xTw1ooIKLqhCCV2Z4d9fdivBbMz3p1Ix/G/ESxsXFVT2TxLw1l3F+GwYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TZ2SrHIQ; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TZ2SrHIQ" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20bc2970df5so23724365ad.3 for ; Sat, 05 Oct 2024 08:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141967; x=1728746767; darn=vger.kernel.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=4X5zP7zXx4H0vSkmfgBSYylbUDArgVMPw2dfqzvhfaA=; b=TZ2SrHIQCgj4Cp3nTnccPw7hKkLUNL/rX5fu5F7zihmvsHTf0a9kCTGeI6dqYXULbN lVRWwaUycJtPicvdWKxgkDE8+OVO0XwRerSisSaN7HJDkTAIqF/JKLfq9T9KrdfTlA70 nRei4gcifpx6HHbqeNGnNBtPVAbnMJgWvUSACJg/ZVLraLnAT8myjbXdNU+61vSuK8y4 2wH/u8Zth7Q6ZPsxeTyFk6dS9sxKNqQnLtQqN3rJbBamdjP+4/ezRvPBXIBFZMi1e9mP /tVaD0Mj6quG1nKs0MiORIE0TNmga2ZgnJ3fjcxc7sKjXQONf+9ASohqsJRbryIob+er fQQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141967; x=1728746767; 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=4X5zP7zXx4H0vSkmfgBSYylbUDArgVMPw2dfqzvhfaA=; b=K0dQnWop3w9PHmQCwyEefbDM2XEV8e9HSIcq5BNBnVnLud+yuWdewLet2vt7ubgjsT HnEvOv6UZuKNUUKFQsNFjNDyiNCebZlDVhVVfIGzCENlzdbf1bNPhKAiePNXnBemNBuM zKC2Mf+osqJst3lGF9TZvLwRJUJQyZizrsPxSI0xfswNhuFE0roDFYe5vFgRhUbfFUiM s/IjScEwfwH+mU5bBmujBrsdd8Sl/SBgljNI51XO7Aw4oiSGX7WrelT15k9v1pvLSFoe 3onUxikyIKKirdKJLr5a1rvnysvReo1qytgf2uXCARI3ICqDTD82gv/o7NSn02pAHkRP ucew== X-Forwarded-Encrypted: i=1; AJvYcCUhAttQxPvt08WU9uYFEn/wuX3fFKWBEf68Mu3f3ANnYM1GsB1O92409uzb2EO+Xf3QJy+wCP/GdXSmnP0=@vger.kernel.org X-Gm-Message-State: AOJu0YwUvNCHr/CspoQX+tQB7/BhUaMYWk2FOcPq8q7rHRcsHvPvCbf2 EitRYY7UMwXiW2G92JW6jQRHYYnGJe1c31+qI3ZGk5Ju/uo03vAqeo4T+hTvy1k= X-Google-Smtp-Source: AGHT+IHY99g3UXT4c2ojVRByg/b7oYD6LPj2/nVP/Gw9LAajOrCDKRjQrnpHrqEZDe38lbLZqZ4qcw== X-Received: by 2002:a17:903:1d0:b0:20b:fa34:7325 with SMTP id d9443c01a7336-20bfe291d4emr83779435ad.43.1728141967491; Sat, 05 Oct 2024 08:26:07 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 15/20] target/arm: Pass MemOp to get_phys_addr_gpc Date: Sat, 5 Oct 2024 08:25:46 -0700 Message-ID: <20241005152551.307923-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Pass the value through from get_phys_addr. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/ptw.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 9af86da597..e92537d8f2 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -81,7 +81,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi); @@ -579,7 +579,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, }; GetPhysAddrResult s2 = { }; - if (get_phys_addr_gpc(env, &s2ptw, addr, MMU_DATA_LOAD, &s2, fi)) { + if (get_phys_addr_gpc(env, &s2ptw, addr, MMU_DATA_LOAD, 0, &s2, fi)) { goto fail; } @@ -3543,7 +3543,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { @@ -3641,7 +3641,8 @@ bool get_phys_addr(CPUARMState *env, vaddr address, } ptw.in_space = ss; - return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); + return get_phys_addr_gpc(env, &ptw, address, access_type, + memop, result, fi); } hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, @@ -3660,7 +3661,7 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, ARMMMUFaultInfo fi = {}; bool ret; - ret = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, &res, &fi); + ret = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, 0, &res, &fi); *attrs = res.f.attrs; if (ret) { From patchwork Sat Oct 5 15:25:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823330 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F180B15383C for ; Sat, 5 Oct 2024 15:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141970; cv=none; b=dLVUP9+X5HSjw4ndQY19kws3mwMQNJtn3+gWLTtAHAjLcHKJGZ5WHHfIy+vged40wfRXnXqlHeaSh7hVeviuyGlBTymQxG0XniTtnx4mgLRF7OC8F84JoX3A0V1IXGpUTsars7YMCHZfOd6h+h2KNgosS5Zf1m5xPtj9MSW8GAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141970; c=relaxed/simple; bh=dwcQYey/qg79IaExNd/1cs7BEFjH0rBox5pjB3rW+tM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uvrSSeFxQw2EXQg/n/kVorhAvGPqhkIt6t696+S0QrmVuNRyZx+y3v6uE31owlRaX2KFoihBWS5njRWvpX3EdkBGZnNzi+LoN9Bq3HqNC1fLlMjEjWxQCh8amh713akaPve3X0nu4qXa2wQ0i/UdIu7EI+vBce+KOdxjLWps4EY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Fmgh+XPc; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Fmgh+XPc" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b8be13cb1so33016895ad.1 for ; Sat, 05 Oct 2024 08:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141968; x=1728746768; darn=vger.kernel.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=3KXMhwqlNY3FEn9X64ijA0SceY+BOiTFnpHj8/s1p5o=; b=Fmgh+XPcYsW0x1AgiX7PlfjS0PSQz6P0bGpTVx6HAuMufq01UWZh2vI8LpGFVh/32U Zum+uSRqRuvhqqn11AlcYCelFnQ+aClM/x7cptB5r13R113oinUhZf5227KIgHobNhSz B6xpPgc3TfA/7DNBLEGS0ScSsyVkJjEAfQY37xOSX3rG6OcqQzNiNOt9fG7Ya+K1Fuxu 5pJ1eWxltooJ2Or9EVb71j3ZLLZ09VytzjXPWppeZcx+CZG0RFZ7MbnQKG/S+AjDenSb t/zG8MSlmbr20IqYFmQqQ0ZbOLgn1sJHtxSY+aCFwfhrO8zyLPiadfsyDjL8VZz0Nlad 8E5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141968; x=1728746768; 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=3KXMhwqlNY3FEn9X64ijA0SceY+BOiTFnpHj8/s1p5o=; b=hq6LNvVJ+tjpFn8qO51CiuNuwIHoZj/L9RyJ1slMsIH2ycT7/Y+c9bPo6wu5m/nH29 A2a4s+j8A0ibTI4PuA1nK1eBzdkgkga39a1u1jKM5J9unXlwA7Mr7EMOUMnejs/PcyWV u0XbnP893QB4e4I1vDRJaYn1fV4WipLj+fhRoyXaR9LhzT20EsoTu+Vhdmzw1AovlRYO ajraUQ8SqsJuqQqPaEHE3/xjl3SdlFd1mEeY3Dt/Gg9GMtDZxMpcHMO4tHI01lwpceKD 7HPsTng+dwIM9ZlKUwqUk8eIV5k9xLNuycYI60qO3z6SPgK+IlxlpPY+P98tZ0Pq0VWB a/LA== X-Forwarded-Encrypted: i=1; AJvYcCXkki9VeQB5Xo4K1FGnrIob2UsK8S89Kd9B5XQi1rIvVpVqJhy0msyw+b3AgVqEadteylqHA5PsrbCilLk=@vger.kernel.org X-Gm-Message-State: AOJu0YwBk/b3MKkhPvMXUTQVskigmj/FVlBaK7fWkOrHaiiafDFZ3Elg LvRbyqT3lRt7jVReJLnFft+qeWiNZu2+DrQ8tDS11+3h16e1QAmX3g7XvD7KqUg= X-Google-Smtp-Source: AGHT+IHoXvMFOA7jUAYxgFVahS1q2i1bg/ajDF/sY9Oymkr8mht01U8RsKNrUl4cngSkkvOkcrfljQ== X-Received: by 2002:a17:902:fc4e:b0:202:4666:f018 with SMTP id d9443c01a7336-20bfdfd2693mr105297675ad.15.1728141968397; Sat, 05 Oct 2024 08:26:08 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 16/20] target/arm: Pass MemOp to get_phys_addr_nogpc Date: Sat, 5 Oct 2024 08:25:47 -0700 Message-ID: <20241005152551.307923-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Pass the value through from get_phys_addr_gpc and get_phys_addr_with_space_nogpc. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/ptw.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index e92537d8f2..0445c3ccf3 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -75,7 +75,7 @@ typedef struct S1Translate { static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi); @@ -3313,7 +3313,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ARMSecuritySpace ipa_space; uint64_t hcr; - ret = get_phys_addr_nogpc(env, ptw, address, access_type, result, fi); + ret = get_phys_addr_nogpc(env, ptw, address, access_type, 0, result, fi); /* If S1 fails, return early. */ if (ret) { @@ -3339,7 +3339,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, result, fi); + ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, 0, result, fi); fi->s2addr = ipa; /* Combine the S1 and S2 perms. */ @@ -3406,7 +3406,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { @@ -3547,7 +3547,8 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { - if (get_phys_addr_nogpc(env, ptw, address, access_type, result, fi)) { + if (get_phys_addr_nogpc(env, ptw, address, access_type, + memop, result, fi)) { return true; } if (!granule_protection_check(env, result->f.phys_addr, @@ -3568,7 +3569,8 @@ bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, .in_mmu_idx = mmu_idx, .in_space = space, }; - return get_phys_addr_nogpc(env, &ptw, address, access_type, result, fi); + return get_phys_addr_nogpc(env, &ptw, address, access_type, + memop, result, fi); } bool get_phys_addr(CPUARMState *env, vaddr address, From patchwork Sat Oct 5 15:25:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823331 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD1AE1C6A3 for ; Sat, 5 Oct 2024 15:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141971; cv=none; b=aoInwsZ7me6366kxeSt8R7xr5I2FK/EfB1/obev4NuIxP6M2Id4wu4xXyNPofpRWVsJ23cWpiqAjvCf6vgJwsw9ZPpzX1D8aSTkoygOh/tNObxJ305N+I4zzHWPd5EuWgABgMOsrNvlzy3MSXMCocuy3w8GHDwQWXVn1sZojPXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141971; c=relaxed/simple; bh=mKNr4HPQW8zX73f98vjtas3HbqrZ2mbpCZvK/LaYaik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ElW+UXndpyAp+9KLjN0WpDF49jxC1As2SQCHxxEjhoXyRhjJu28EXiGOxE3Vfo5qqPpV/vfbp68g44Y4pP9MI2uFvfU8Frmmk2XyPHpfE8Pq5rqcwn+Go8kyAPLQA3JxaRsxH6PBtTY8YJzDnUQjvy9qP02YCUU6q9G//s8u3XU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=g+5LvH+F; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g+5LvH+F" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20b5affde14so24156465ad.3 for ; Sat, 05 Oct 2024 08:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141969; x=1728746769; darn=vger.kernel.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=oB3S/z+Tf/YurYPbjZAkQ2iOmy2pkllXkguo9aONGm0=; b=g+5LvH+FqdXlNv0wBY9hflMYh4rFuINTgWXElWYyDiqLO0eTgw1dal2FfGXuo/WI5X OgGIhE/Twf+ne/su2aKcpZBSjE2avXZFpX4iAJifPL3gwwo19OCXiE5MIxCqgLFHjwtY 8j4runxNAR+g0BCud2RVx0Io6s/9xulWAz8PLP4WEnaqgpKxt2MEBd3/gk7T3VpVLONl i/GGCqanaRDeHUhlQUTz4Bz6d0Wo8aAn7jAZ3U7Ol6o1+V282uanVqfv+V0yxsOzwS1c BXDnRxkcVWjL3f5NfvTk+FQjo3dzL5rPLNU7+RymudAyR1499+eBJ2117BP/d3nuyaFX cSbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141969; x=1728746769; 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=oB3S/z+Tf/YurYPbjZAkQ2iOmy2pkllXkguo9aONGm0=; b=ACldlXtXdmYmZ6YnH+BMUP6h2zCoZLHp3inqgFOzE3U9eDEU/aNraJCxd4wlqkuXKR 8/KaDpyKbmZtVbg8IkeqWMtMPvjkGmrosJUpXAAweXj6NrERQ/knf6sR/M9LjZM86T3h AODHWzmEVgWkGZ6zq0i3XqLwwq36C6+t2ILeXIIsPsXNOO8V6soZCFY6zGjl8FjJNA3a gAKmlccF3gaZAd/T0YCh9h0vVdg9U9swKa+Lc4dDXHrQy7Xr4hgunaE/jRMT9U2x5L4K 3fl2clhBDUKnDupH8MHXFxyRu47HroCpB5liMnHjOEBcCXWZBV+N7fjMj0zIV4w3Dcpz yPOA== X-Forwarded-Encrypted: i=1; AJvYcCVmr8cOFG5sPTCBzDCWvHjJFG2RcW2FIpLSkxvGqMcWhTNiPfiVGhMLyT+kymrWN1QeLo6vMtE3YLPd2aU=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ7QpNUPr2y7tm9Aw+CvPFD2tLOsuwylX5Tm2GpU67yVoyPKlr sjk2vEZi6Kn5m72R7jkWWZEY5kEB/q9l4pe1hFMA797DUkH1T5G8I4bkGVxEIq4= X-Google-Smtp-Source: AGHT+IHGjDyFhoX1JFcZLwPMzIWk0VZ6VyK/OgPBEe0dpV3tD5qpqz+OhbMKSWs06HyBvYG2qhd0Ew== X-Received: by 2002:a17:903:2343:b0:20b:8924:3a77 with SMTP id d9443c01a7336-20bfe071396mr82155675ad.26.1728141969294; Sat, 05 Oct 2024 08:26:09 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 17/20] target/arm: Pass MemOp through get_phys_addr_twostage Date: Sat, 5 Oct 2024 08:25:48 -0700 Message-ID: <20241005152551.307923-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass memop through get_phys_addr_twostage with its recursion with get_phys_addr_nogpc. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/ptw.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0445c3ccf3..f1fca086a4 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3301,7 +3301,7 @@ static bool get_phys_addr_disabled(CPUARMState *env, static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { @@ -3313,7 +3313,8 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ARMSecuritySpace ipa_space; uint64_t hcr; - ret = get_phys_addr_nogpc(env, ptw, address, access_type, 0, result, fi); + ret = get_phys_addr_nogpc(env, ptw, address, access_type, + memop, result, fi); /* If S1 fails, return early. */ if (ret) { @@ -3339,7 +3340,8 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, 0, result, fi); + ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, + memop, result, fi); fi->s2addr = ipa; /* Combine the S1 and S2 perms. */ @@ -3469,7 +3471,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, if (arm_feature(env, ARM_FEATURE_EL2) && !regime_translation_disabled(env, ARMMMUIdx_Stage2, ptw->in_space)) { return get_phys_addr_twostage(env, ptw, address, access_type, - result, fi); + memop, result, fi); } /* fall through */ From patchwork Sat Oct 5 15:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823332 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4D8F15383C for ; Sat, 5 Oct 2024 15:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141972; cv=none; b=TmsROpQ0N3rrFLUyhDR3HIkigJDSPvPjWy5e0i2C4b4Xca2cbr1wKqPgmdvSfnpUy5SGHT1JEQn1Ga89xEPvQuSRCEJKXTJbTSdx/IOIEsa7WQrJJdfuVufCaF5CDbIZbUibkHYpN+TcZDBW9FSgxFU11bsScwDMxEXyyPHBU6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141972; c=relaxed/simple; bh=vw+vuHfKefsP5JRxOVj5kr//br775m5Gcy+Gi29V22g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s+JVhOcpHh5Trohpi4UgJjGgJK2UO2YPSUwtjRNKxA5skf+CNRSlk34pmP9MB1hy72StXCvejux7zNsKe6PWFI/ZJz+GA0XxlOI9XzADK2/IpnEapa+AhJuMYAvOVVhMi+DpFd8ecPa3IKOJx1K8jyPEmrI2Dzn4KRwvzDEHWRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=M1isaE/q; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M1isaE/q" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20b58f2e1f4so21135125ad.2 for ; Sat, 05 Oct 2024 08:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141970; x=1728746770; darn=vger.kernel.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=9tqb0TUsQOZF/sRJ8YxWqhKeQa3g/EH2JXyCvd2UdW4=; b=M1isaE/qn5tdyqJIsxZ2M8NyO+9pcbOKdFKWb95t15Y8+vD2Us/TiXHN/eFktvkmto fxs/yH8y4hWOApqa1HPxlnGFuSFnhiISH3+f2N8SMKTFYu2155+wRjxkXNHcPYEDyTiV EOcex/RZt1ODYlxRzYWB2fMiVPdD/TNpphCWsss62yoedtY+5kIplMtlZsW5TqtpTOdq ZUhO2zQCATc/RafaCa3OsP7DJbZIBaUEoStpH7PwEAvI/4LgkoVa/qCxbwv/1JGksstz rGhR1MKqfZnSwxOaBK5BvDwhFHEOzmMcNVg/E/lAQj2nWG2nvwyxnMuDnda9RnD7ZAKw VADQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141970; x=1728746770; 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=9tqb0TUsQOZF/sRJ8YxWqhKeQa3g/EH2JXyCvd2UdW4=; b=d+aJmtAz/aEi1y98KnVETzok+WLlSE7seY6TncFH/ztEUGBNBAQhchs/Id03k9UOGa 4ay0g/PB80xBe1VvMefufq63Q0px6XzexuQ2x+UCoOZ7KbbDeAAuXzjlxPhZayD1lMeB SM4OiHFuqvtdVls5BGeWR+6cwyI7GrdZ1smLVrymih7d7E6i+0oHgdFCa+dJd2iA8VTN sECIWsWWnPkpy3FLwwLvfpsGRLqjHfj7lWr91FBV0xk31Xq2WWBeYDwJqGIyi2jhGWdf GHA34SCV7aDR9ZVaTwn8YgAm+a0qDjf1usz9dDiWiCClQXZOt93dNEpjHqmqXzMkyTad tZzw== X-Forwarded-Encrypted: i=1; AJvYcCXwd5lbVqzjNIBr9ckHGje2lJl0LV4PlJZHxfUyZ65gqXIb60asPfqYJ7aiPyultYU8VmZbu7uwfw3kTCI=@vger.kernel.org X-Gm-Message-State: AOJu0YwMI5MqvzO1zHVEU6MOqJwHb3kLdQcAzpYN50l9hda6klqIAZSH No+yqGsilL9N6zTpUDhZRyM1IB3GTicIHUarw96mGfRMxQ8zs4ADnIBnOBYh7gE= X-Google-Smtp-Source: AGHT+IHAcc49fQDj+6dUv1WwyItmZo+VQhDVyFSsiB0HVGJtSbOyDZXUNQcKgpb3qKjj8UutpLm7Eg== X-Received: by 2002:a17:902:d2d0:b0:20b:be06:f3d9 with SMTP id d9443c01a7336-20bfe1887c8mr91971805ad.24.1728141970334; Sat, 05 Oct 2024 08:26:10 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 18/20] target/arm: Pass MemOp to get_phys_addr_lpae Date: Sat, 5 Oct 2024 08:25:49 -0700 Message-ID: <20241005152551.307923-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass the value through from get_phys_addr_nogpc. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/ptw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index f1fca086a4..238b2c92a9 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1684,12 +1684,13 @@ static bool nv_nv1_enabled(CPUARMState *env, S1Translate *ptw) * @ptw: Current and next stage parameters for the walk. * @address: virtual address to get physical address for * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH + * @memop: memory operation feeding this access, or 0 for none * @result: set on translation success, * @fi: set to fault info if the translation fails */ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, uint64_t address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { ARMCPU *cpu = env_archcpu(env); @@ -3534,7 +3535,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, } if (regime_using_lpae_format(env, mmu_idx)) { - return get_phys_addr_lpae(env, ptw, address, access_type, result, fi); + return get_phys_addr_lpae(env, ptw, address, access_type, + memop, result, fi); } else if (arm_feature(env, ARM_FEATURE_V7) || regime_sctlr(env, mmu_idx) & SCTLR_XP) { return get_phys_addr_v6(env, ptw, address, access_type, result, fi); From patchwork Sat Oct 5 15:25:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823333 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE78C1553AB for ; Sat, 5 Oct 2024 15:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141973; cv=none; b=TiykGOM661lXNi3XQ/yVHBQrJxDsX5CHfVgrtOHV2NZ73WiYIs72aEFk3R47+C1hbsN4svs11+uTrz3IG/XkZhOgWSGUWjZi6ceERkujSbyrW/v2rGXsqtBQNUQPH4+5G91TDnsT8gkskJHb8e9nN1Or5DnWpQ5MJfit+FOqAwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141973; c=relaxed/simple; bh=GfbgeWhvJZEkGvmTmmQeIHTRaV4I16CMz8q34Fkno2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K+/TZIzedPnT98Zptb3lAP0puLgxnC6prgR1v/AXjNvxa/mYXAMLDMpGRQcyR0FM+SG3fyTS47Ev41/xCk+wFAghXaK5IyGL8y2gm+i4/lsGuCiABOePrSYRuItg2vts1HPvZio7AXgTz+ipkq67iRnfQolbtqQY1NJLoAhPllg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NffT4kpz; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NffT4kpz" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20b9b35c7c7so21873735ad.1 for ; Sat, 05 Oct 2024 08:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141971; x=1728746771; darn=vger.kernel.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=/ZHU/9Bj/Yhl/fLIAf9ED9KKjqQvRkGT+c+Pl2SvUJY=; b=NffT4kpzzxd6DQd5jJdUKa8hGZ3qNwM3+lu7URzErJuu1vROFh0YQLEMC8YDDA8T4F JtpjCXgnhJhjosXzPjQK2TRVWR9Y+Vl1n2itjsuxeb/Y3IV8nAS5MwgMntaSYlea2z/r 4s6sK4KAUyZQgMOiXlDzRXxOCdL4fVgL7+D79RvroyJwLrl2rJ8ns6YmIizTQMVLmeI2 WMk4WvODr6B6cYrVMlLzAv1YdFZYoLTqvLiQO2fkeCNaq7js9TnLDJRFvBAIhAe2COBI CKMTQJ5A+pKHrDJQc5r4TN5q3qjDwFw4SuVP1xhfN7hYuQn9ZxJeMFtDDZPPUgE5A+ia uv6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141971; x=1728746771; 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=/ZHU/9Bj/Yhl/fLIAf9ED9KKjqQvRkGT+c+Pl2SvUJY=; b=fCIBuXH0UlzatibNqjYEAmf4Y7/380khgmXipIyP5hF6LU7cnaKO9PrRVfQQStuRP7 Z4tAfjJ7M/RkQTPwm76a9cZZHF/IhRZdnjqglB1HbATHoLNxAubIcIb/E+Po2XBip0b8 DC7VGsPEJ7ibk4EuFQwJ7glpRS3JdFeoF8zjTs1UAWKSZuQvpJnLNEx4A60q9fA7lnvt KRNT+fQDN+LQa13hAc0eeilujWm6ixwL67ubBzW7A6S9V6UePLEnFe97J7FE1Q3dhG0r P8NLn1nca6Z1Bww222/rV3Kwv73Ch/wW5ANm+AMZzqSBOKOivIayOgBraG/byiXnzJK3 fB8g== X-Forwarded-Encrypted: i=1; AJvYcCXEe6S4bVzQjUQ/XuqKGkyv/XTj550fhCbggosomnl3EAmZGJ2u8VlRzd5IcZFC0oXsqZzY4mzzF3AZz7w=@vger.kernel.org X-Gm-Message-State: AOJu0YyBIpo8a1MjTxM8aYFvst34R2MQHP4PJd3pUsIkr3q3XRvVJVM3 2+8UHZQUp460/duVisYOmXL1OF/bKDnF71HTgWpsHypl8+UdpZEuly2Eb0SQT9E= X-Google-Smtp-Source: AGHT+IH4Lr64SQZfzlOO2MyBkQGMuSWCJxA1Uid5flyT3IfspQk+qHg9k3FYTQCTF9/9yq+5XQ2JSg== X-Received: by 2002:a17:903:2b07:b0:20b:8e18:a395 with SMTP id d9443c01a7336-20bfe291f03mr89154495ad.44.1728141971365; Sat, 05 Oct 2024 08:26:11 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 19/20] target/arm: Move device detection earlier in get_phys_addr_lpae Date: Sat, 5 Oct 2024 08:25:50 -0700 Message-ID: <20241005152551.307923-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Determine cache attributes, and thence Device vs Normal memory, earlier in the function. We have an existing regime_is_stage2 if block into which this can be slotted. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 238b2c92a9..0a1a820362 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2029,8 +2029,20 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, xn = extract64(attrs, 53, 2); result->f.prot = get_S2prot(env, ap, xn, ptw->in_s1_is_el0); } + + result->cacheattrs.is_s2_format = true; + result->cacheattrs.attrs = extract32(attrs, 2, 4); + /* + * Security state does not really affect HCR_EL2.FWB; + * we only need to filter FWB for aa32 or other FEAT. + */ + device = S2_attrs_are_device(arm_hcr_el2_eff(env), + result->cacheattrs.attrs); } else { int nse, ns = extract32(attrs, 5, 1); + uint8_t attrindx; + uint64_t mair; + switch (out_space) { case ARMSS_Root: /* @@ -2102,6 +2114,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, */ result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, xn, pxn, result->f.attrs.space, out_space); + + /* Index into MAIR registers for cache attributes */ + attrindx = extract32(attrs, 2, 3); + mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; + assert(attrindx <= 7); + result->cacheattrs.is_s2_format = false; + result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); + + /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ + if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { + result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */ + } + device = S1_attrs_are_device(result->cacheattrs.attrs); } if (!(result->f.prot & (1 << access_type))) { @@ -2131,30 +2156,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.attrs.space = out_space; result->f.attrs.secure = arm_space_is_secure(out_space); - if (regime_is_stage2(mmu_idx)) { - result->cacheattrs.is_s2_format = true; - result->cacheattrs.attrs = extract32(attrs, 2, 4); - /* - * Security state does not really affect HCR_EL2.FWB; - * we only need to filter FWB for aa32 or other FEAT. - */ - device = S2_attrs_are_device(arm_hcr_el2_eff(env), - result->cacheattrs.attrs); - } else { - /* Index into MAIR registers for cache attributes */ - uint8_t attrindx = extract32(attrs, 2, 3); - uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; - assert(attrindx <= 7); - result->cacheattrs.is_s2_format = false; - result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); - - /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ - if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { - result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */ - } - device = S1_attrs_are_device(result->cacheattrs.attrs); - } - /* * Enable alignment checks on Device memory. * From patchwork Sat Oct 5 15:25:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13823334 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D75F6156230 for ; Sat, 5 Oct 2024 15:26:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141974; cv=none; b=JNfjNNDVs8wJI9cwARdH+/wyv3M51514DpVbEzv0WdBiLaf3JODy8zx/SouWecTJIPPz6dTg835fw0tY0PCwbtMyimZEd62jN7irGkAdl7q+PJpzzxX0Eyj7kLQ274lukziijqlpZYUfb1TkAIHuDzjW9nLDZfBUM8TUC6Mt/1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728141974; c=relaxed/simple; bh=huD5NidbYXV5yWa6IFJz9jG5pO7wgoHT97Pb6ytfppc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EWlSzER6/ekTd6iWfMfLpqwmuT626HINPcMBu40n1kW8L+FDiZV+dkC26DBgRuP3SrDydwS+/o7CXhO9ZqPhD1A1TuvxhIRoAO88ahv5VKjuJ4lBhivqRMOdwAYxhclCoGHeAtbUKlH9cNN1W7YPVjYgZRxgrwDnP7Jo61kZpXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=MgwlxTE/; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MgwlxTE/" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20b78ee6298so19961215ad.2 for ; Sat, 05 Oct 2024 08:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141972; x=1728746772; darn=vger.kernel.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=qIlBHpyIHO+kiCFyGgZVBXgacr4yw5gCrMn63zUSz3U=; b=MgwlxTE/Xkd267sv+4nV0HXsWBMGQfHQvmCx0PvRVBJqZ2pU1PCdEzlYHmD6PDEcW6 uzMdOPpcxjKmf2R2oOk8RtDUIfQayLG9Aw5yJBee1KkdnA6C5JUvoEZaYvp9QfbVqkzr n4bp7kJiOpvW+h3LIVvtwY5jBOlUnLgZjlUk9GRpuRz7lzfRK88i60APLzsK/wRsaqPP dS32fZiW64sdjRcbgok4dP1EsEJnkaLpUVw+fqnM+7EV8Lcp0B2xmDpGv6PKmQGpx0gX buHXA6Nj1GnLX7tOQfJkKw8/+3UolnXUxFvG7vjc6WkZxf81r/KQ334CCN+9de1MgHmD sE1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141972; x=1728746772; 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=qIlBHpyIHO+kiCFyGgZVBXgacr4yw5gCrMn63zUSz3U=; b=Ot9sl3TS9zPvV1rS8IGHMc3gImnaYA/R54Gr9M/bCByUuSLpcEO5rnIr14XraNsoOL Q26tREcrxaUANAKNYV9E2KeCZGJ+aD25W6MzS0eSw6BZtoPc82bjkDnXP5k1CTWjVH3I XCsbS3txgO+P5YAcEn/gj9KA2ftz/OMcO9pJWgM6WN6xDv4hQZhxSZJAg6ZqqHtwNO7W LWU8+Yge8XsYFThE4WDLaMHW5TphIuRj1xoGubA/v2RvSExz6U7tAAR6KyZlddDmssHO NBYVoJS+i64q7mPiV2rDDqratU39L2R8l0pwX7zogXA4RbDYAxE7qGP9tvHwJzpnMuFa C0HQ== X-Forwarded-Encrypted: i=1; AJvYcCWlGV+ryBFci8/fWKUw9gJAQxrFizTH76OUvXhFaKB7oQgELg60T5U+MlenP3tyfKIxOGHkA04qxti+gnM=@vger.kernel.org X-Gm-Message-State: AOJu0YwLN9wbrhnVl15Yl98KKCnGPjbq+jhA+DB5ghMcMIE5cQYYd3X1 DlB84cic4wlNqrmv+2n7hhqFfWfrywwbFKVTvwrJ7g+/5cOqsu1Xusbv2vt+lHDGDNqgDOGaN0a C X-Google-Smtp-Source: AGHT+IGWHKPtHA2twxKvGB6E/ujF3z3IoFDGiLN3geSfu/MXfka4dtEv6hp0P2DmLjyD/i9iV2pkew== X-Received: by 2002:a17:902:d2d1:b0:20b:9547:9b2d with SMTP id d9443c01a7336-20bfde55510mr91868295ad.2.1728141972285; Sat, 05 Oct 2024 08:26:12 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:26:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH 20/20] target/arm: Fix alignment fault priority in get_phys_addr_lpae Date: Sat, 5 Oct 2024 08:25:51 -0700 Message-ID: <20241005152551.307923-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that we have the MemOp for the access, we can order the alignment fault caused by memory type before the permission fault for the page. For subsequent page hits, permission and stage 2 checks are known to pass, and so the TLB_CHECK_ALIGNED fault raised in generic code is not mis-ordered. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 49 +++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0a1a820362..50aa5e338c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2129,6 +2129,34 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, device = S1_attrs_are_device(result->cacheattrs.attrs); } + /* + * Enable alignment checks on Device memory. + * + * Per R_XCHFJ, the correct ordering for alignment, permission, + * and stage 2 faults is: + * - Alignment fault caused by the memory type + * - Permission fault + * - A stage 2 fault on the memory access + * Perform the alignment check now, so that we recognize it in + * the correct order. Set TLB_CHECK_ALIGNED so that any subsequent + * softmmu tlb hit will also check the alignment. + * + * In v7, for a CPU without the Virtualization Extensions this + * access is UNPREDICTABLE; we choose to make it take the alignment + * fault as is required for a v7VE CPU. (QEMU doesn't emulate any + * CPUs with ARM_FEATURE_LPAE but not ARM_FEATURE_V7VE anyway.) + */ + if (device) { + unsigned a_bits = memop_atomicity_bits(memop); + if (address & ((1 << a_bits) - 1)) { + fi->type = ARMFault_Alignment; + goto do_fault; + } + result->f.tlb_fill_flags = TLB_CHECK_ALIGNED; + } else { + result->f.tlb_fill_flags = 0; + } + if (!(result->f.prot & (1 << access_type))) { fi->type = ARMFault_Permission; goto do_fault; @@ -2156,27 +2184,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.attrs.space = out_space; result->f.attrs.secure = arm_space_is_secure(out_space); - /* - * Enable alignment checks on Device memory. - * - * Per R_XCHFJ, this check is mis-ordered. The correct ordering - * for alignment, permission, and stage 2 faults should be: - * - Alignment fault caused by the memory type - * - Permission fault - * - A stage 2 fault on the memory access - * but due to the way the TCG softmmu TLB operates, we will have - * implicitly done the permission check and the stage2 lookup in - * finding the TLB entry, so the alignment check cannot be done sooner. - * - * In v7, for a CPU without the Virtualization Extensions this - * access is UNPREDICTABLE; we choose to make it take the alignment - * fault as is required for a v7VE CPU. (QEMU doesn't emulate any - * CPUs with ARM_FEATURE_LPAE but not ARM_FEATURE_V7VE anyway.) - */ - if (device) { - result->f.tlb_fill_flags |= TLB_CHECK_ALIGNED; - } - /* * For FEAT_LPA2 and effective DS, the SH field in the attributes * was re-purposed for output address bits. The SH attribute in