From patchwork Tue Feb 27 22:24:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Komlodi X-Patchwork-Id: 1905468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=34sq/53O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TksWm2slpz23d3 for ; Wed, 28 Feb 2024 09:25:56 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf5sD-0006tI-1a; Tue, 27 Feb 2024 17:24:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3FGHeZQcKCoUtxvuxmrpxxpun.lxvznv3-mn4nuwxwpw3.x0p@flex--komlodi.bounces.google.com>) id 1rf5sB-0006sn-Cb for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:27 -0500 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3FGHeZQcKCoUtxvuxmrpxxpun.lxvznv3-mn4nuwxwpw3.x0p@flex--komlodi.bounces.google.com>) id 1rf5s7-0008Hw-4M for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:27 -0500 Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-5c66a69ec8eso3696651a12.3 for ; Tue, 27 Feb 2024 14:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709072661; x=1709677461; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+xSYC9woE8ejU2ZMzJv9wgrGS4seNQMp4/9INbjIsDE=; b=34sq/53O+T8R2ea8sr7D5zNezT7xqN5PqIxcLHDNhMwn/1Va71noEvGUOjJc3TtMwV 4EUQ0/Kvk34xQ93pOXakuFRFAJIG8+bbtjxIDNLd9gz+T8OKVX/zqE2MyI9O80dxeOuX gMQyfNDHPoIGOVE/AhwDMOeHoggQOdIeIK2bsZuOj0dLMDaYWJuK4lPhWkZH5h0TtiNz eom0Hafi5y15BAeQEnbKJ5xGHvRcRhjIhgvU+KyB/HnBr9djW4lyPDP6egTF7K5X2S3k awW4wnFEe5yAZumgFJBznhom/ss3lEpa/eQvtfe5vByOAG4hR8N+wg+fGy0CUMl4NrhF 4IYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709072661; x=1709677461; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+xSYC9woE8ejU2ZMzJv9wgrGS4seNQMp4/9INbjIsDE=; b=o/zW02DTaQe+JZxamPhiIxjZH5lH3IlxnhV370nyGhq4ojU9MTW/mPyv3OcHHRMOxr /+aY4AaYqoh8K80oqUdDeb/xYKcf4VB+BG3v3QRB2q/njQqy5QQNYh8+nclWQPG4qSw6 bvyMxBu/DaqywkUF0Nvj5TjhyRBGm3LcCGl0N65Mp/XbswJ6UPv6jb0Ob567ems24aCN zlaQBc1rAcWs7mY3Y+7ucS71OyiuegZfuRlKX1+A3aU34SrmRjguJ+uT2CCJrkSQKknF RjUw7TR8X65gmHbwMJT8BV5/qVMWwR7qAkzp4dx/PXoFEjkaRc5lv9MdXlR8Q98v/nuR QXQA== X-Gm-Message-State: AOJu0YwOAwpjS32uX6OJgSTAyGkLBQ5EiZqVdPkeVFwVLNUTP6aR7NNm sVk1Y7GZekbkq9ePMFRbECuwAbWmrWdA3y7bFXipW2+oEgOAKjuxbu9UomrTrqG/URf/NSwdxrq zc+GCtkRCPME8DPMjhYObAMtLld/Kz2JYfd13qu4ovc5IMyztBkr+0rkVD4G4wiwj9yZF+3Me6+ UDMQLXrNYfixA1oX3JzW1nS/zE7xN8+KQJYbUk X-Google-Smtp-Source: AGHT+IHsEXKg30e7rEt6uzwaJM+AGs9+9OuSrjMAijwMmYmczmtWBV0xD9Cmg+Y0rhupt3k7vwf5BVqU9ITM X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a65:6753:0:b0:5ce:6c6:6973 with SMTP id c19-20020a656753000000b005ce06c66973mr49128pgu.8.1709072660644; Tue, 27 Feb 2024 14:24:20 -0800 (PST) Date: Tue, 27 Feb 2024 22:24:13 +0000 In-Reply-To: <20240227222417.929367-1-komlodi@google.com> Mime-Version: 1.0 References: <20240227222417.929367-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240227222417.929367-2-komlodi@google.com> Subject: [RFC PATCH 1/5] target/arm: Add requester ID to memattrs From: Joe Komlodi To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, peterx@redhat.com, david@redhat.com, peter.maydell@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, philmd@linaro.org, roqueh@google.com, slongfield@google.com, komlodi@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::54a; envelope-from=3FGHeZQcKCoUtxvuxmrpxxpun.lxvznv3-mn4nuwxwpw3.x0p@flex--komlodi.bounces.google.com; helo=mail-pg1-x54a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org I've seen a few different instances where a CPU or a memory region is behind some sort of IOMMU, and the IOMMU translates (or denies) accesses based on the requester ID of the CPU. This patch only does it on ARM CPUs, because I did not see CPU-agnostic code that added CPU attributes when creating TLBs. Similarly, we add the requester ID during PTW, while populating the rest of the memory attributes. We add the requester ID during GPC and descriptor grabbing as well as PTWs. Signed-off-by: Joe Komlodi --- target/arm/cpu.c | 4 ++++ target/arm/cpu.h | 6 ++++++ target/arm/ptw.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 5fa86bc8d5..9cfbba10c2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2402,6 +2402,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } } + /* For MemTxAttrs. */ + env->requester_id = cpu->requester_id; + qemu_init_vcpu(cs); cpu_reset(cs); @@ -2439,6 +2442,7 @@ static Property arm_cpu_properties[] = { mp_affinity, ARM64_AFFINITY_INVALID), DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), + DEFINE_PROP_UINT16("requester-id", ARMCPU, requester_id, 0), DEFINE_PROP_END_OF_LIST() }; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 63f31e0d98..5fc572e077 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -774,6 +774,9 @@ typedef struct CPUArchState { /* Linux syscall tagged address support */ bool tagged_addr_enable; #endif + + /* For MemTxAttrs. */ + uint16_t requester_id; } CPUARMState; static inline void set_feature(CPUARMState *env, int feature) @@ -1091,6 +1094,9 @@ struct ArchCPU { /* Generic timer counter frequency, in Hz */ uint64_t gt_cntfrq_hz; + + /* Requester ID, used in MemTxAttrs. */ + uint16_t requester_id; }; typedef struct ARMCPUInfo { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5eb3577bcd..148af3a000 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -287,6 +287,7 @@ static bool granule_protection_check(CPUARMState *env, uint64_t paddress, MemTxAttrs attrs = { .secure = true, .space = ARMSS_Root, + .requester_id = env->requester_id, }; ARMCPU *cpu = env_archcpu(env); uint64_t gpccr = env->cp15.gpccr_el3; @@ -638,6 +639,7 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, MemTxAttrs attrs = { .space = ptw->out_space, .secure = arm_space_is_secure(ptw->out_space), + .requester_id = env->requester_id, }; AddressSpace *as = arm_addressspace(cs, attrs); MemTxResult result = MEMTX_OK; @@ -684,6 +686,7 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, MemTxAttrs attrs = { .space = ptw->out_space, .secure = arm_space_is_secure(ptw->out_space), + .requester_id = env->requester_id, }; AddressSpace *as = arm_addressspace(cs, attrs); MemTxResult result = MEMTX_OK; @@ -3306,6 +3309,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, result->f.attrs.space = ptw->in_space; result->f.attrs.secure = arm_space_is_secure(ptw->in_space); + result->f.attrs.requester_id = env->requester_id; + switch (mmu_idx) { case ARMMMUIdx_Phys_S: case ARMMMUIdx_Phys_NS: From patchwork Tue Feb 27 22:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Komlodi X-Patchwork-Id: 1905465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=stNPHNeO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TksWL6Dsnz23d3 for ; Wed, 28 Feb 2024 09:25:34 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf5sE-0006tu-CS; Tue, 27 Feb 2024 17:24:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3FmHeZQcKCocvzxwzotrzzrwp.nzx1px5-op6pwyzyry5.z2r@flex--komlodi.bounces.google.com>) id 1rf5sD-0006tM-3E for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:29 -0500 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3FmHeZQcKCocvzxwzotrzzrwp.nzx1px5-op6pwyzyry5.z2r@flex--komlodi.bounces.google.com>) id 1rf5sA-0008IS-IT for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:28 -0500 Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-5dc91de351fso205518a12.0 for ; Tue, 27 Feb 2024 14:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709072664; x=1709677464; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=oJDukn7jW1vPTXeJS7ppBd1/pnfVtWKCS5OuUBMJ9W8=; b=stNPHNeOUJytjz4xgYZRJWK3fzMjITnr3s9vu/bS8lAEWYxmdWNCbWqhncplYsuNfn pXyrjWlkTunl67hiLqy36WVKYnNAf6VUMH4mRFguPZGb07bhI9g0CYaMfODGdhu7CWsu 8RdVu1tS9FMGgNoM7kav9OgZG6uIJhAcSYvGKifsoy1Eh1I6LJLCK8+jLugnUrs+o7hV dihbjTgC6BZKIFYvbMPA0KmmzEEngQOaoJTGPBVBhxnvp8xiLect+KQfBmYBAZanvl+G qMGcMU2iZGN24m3URw0wqGYWMi8/N0IxrHmUDqRz1FL1wcH0qz2olU7otptd2nB0mAvE pu7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709072664; x=1709677464; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oJDukn7jW1vPTXeJS7ppBd1/pnfVtWKCS5OuUBMJ9W8=; b=GXqKEmNsyvCjN70FAJ6umv/77ZUmdzCl43jUDmU4IG58hOKU9+xu+6IDa0AP+Zs8H2 GyJZekYqwQ7YKwfBSUPAJwK3ySJXx9W95JayTFYRyzfRsy6dknxDF/wCTLKACAzDtMgE +itTxDvje0SJp9B/E23+i237UGEzYbql0emyZR1pNYCzWVKJbW0hhDXDLy+m2oiM60SR nVCGbC8A10AYS7PDPkMYGZVzFDDYb/eJZjmgqj1TvzdMmWJDohHVxRtZvSPXasTwAycp Z/tvv+S3It5POYQE1pCXPw7Y2EuGP96N63ESB4YzrwHFDByQoZmbn1ZFIeGSh0vZZS4g sWkA== X-Gm-Message-State: AOJu0YzV2nQQvjBguDdkfCpA7wj06RnhfynOJdPhbJiUlDR47KLxJAwY +C7X35gF28xBfNOa5LFiEHz+Zyn/0OZZtCIRDbqNyW+gVLacNhl3jEItJQK9fCDU9F4FUlmy1HZ 195XuAJw6EASv04bRcQEt72Ye3+m2iikOZkn3DUSF0DmtITH41q0YWf6ISf1UsTTeFi74xPvXTm rZVCe12WLjjFRPxBSn74O1i0gnFo9zxes51xAY X-Google-Smtp-Source: AGHT+IErXylakRUR7HUDs3S+pqp50CQbxUZaWDGFRtWotdrZ4SwK1kkj4mavYgHJcx6+pAr1SXPphY27Di+O X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a65:6956:0:b0:5dc:36c7:6ceb with SMTP id w22-20020a656956000000b005dc36c76cebmr1761pgq.1.1709072662472; Tue, 27 Feb 2024 14:24:22 -0800 (PST) Date: Tue, 27 Feb 2024 22:24:14 +0000 In-Reply-To: <20240227222417.929367-1-komlodi@google.com> Mime-Version: 1.0 References: <20240227222417.929367-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240227222417.929367-3-komlodi@google.com> Subject: [RFC PATCH 2/5] memattrs: Fix target_tlb_bit whitespace From: Joe Komlodi To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, peterx@redhat.com, david@redhat.com, peter.maydell@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, philmd@linaro.org, roqueh@google.com, slongfield@google.com, komlodi@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::54a; envelope-from=3FmHeZQcKCocvzxwzotrzzrwp.nzx1px5-op6pwyzyry5.z2r@flex--komlodi.bounces.google.com; helo=mail-pg1-x54a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org checkpatch.pl doesn't like these spaces around the colon, so we may as well fix it up. No functional change. Signed-off-by: Joe Komlodi --- include/exec/memattrs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index d04170aa27..942b721be8 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -61,9 +61,9 @@ typedef struct MemTxAttrs { * and has unused bits. These fields will be read by target-specific * helpers using env->iotlb[mmu_idx][tlb_index()].attrs.target_tlb_bitN. */ - unsigned int target_tlb_bit0 : 1; - unsigned int target_tlb_bit1 : 1; - unsigned int target_tlb_bit2 : 1; + unsigned int target_tlb_bit0:1; + unsigned int target_tlb_bit1:1; + unsigned int target_tlb_bit2:1; } MemTxAttrs; /* Bus masters which don't specify any attributes will get this, From patchwork Tue Feb 27 22:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Komlodi X-Patchwork-Id: 1905470 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=ukz7GQZe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TksWq0Fqhz23qG for ; Wed, 28 Feb 2024 09:25:59 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf5sD-0006tl-QU; Tue, 27 Feb 2024 17:24:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3GGHeZQcKCokx1zy1qvt11tyr.p1z3rz7-qr8ry010t07.14t@flex--komlodi.bounces.google.com>) id 1rf5sC-0006t2-3B for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:28 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3GGHeZQcKCokx1zy1qvt11tyr.p1z3rz7-qr8ry010t07.14t@flex--komlodi.bounces.google.com>) id 1rf5sA-0008IW-IZ for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:27 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dc743cc50a6so6763164276.2 for ; Tue, 27 Feb 2024 14:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709072664; x=1709677464; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RLGdV4kCAjCSXP14B/AK52peEdH2FKlj4vlWN33bwOc=; b=ukz7GQZe8VZZK9yv4+c2s6BQxMT2CekAdeEtjt4U1tWHMCSE33MFAJQAGsvzmfV8k4 UtGyRS9AzW8Jqvmu1DakLk/kGcRfZLiTjef5d3sLUNsgNxhYGaqGJitE8bNq14dSZe60 GbN3q/dvyHKH8apRKiE5W68ZebfxdZYrY1SqiTeQtBzs0WNzlH5K6dByb+dNTJwXUsQX vm09KGrCO5T3b+twcSdQ1mHMBGWNz9ssEo28UBZtSi9YAFSwonnUMslrFAAEXcfLgr4r vf+tn5EkoSmE7UgfQDf3NH6VTuwHu6HPo04YFv0bZir1HWwjtWzgRMq/YhlRUtPJ1l0z WJ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709072664; x=1709677464; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RLGdV4kCAjCSXP14B/AK52peEdH2FKlj4vlWN33bwOc=; b=WbckIXJ78xzICF/bmVX/9e7B98fhb2vPpVsqGjjxxF4emZyANu2wpTbpixxrNJ+29E GFDP2BOE1y0xN3T4eVqW0qlVmqWJgGKrLC38h+yvm8+Oqmrznt7fwBvGujm8yMUQgVM6 AWCna2FzZDRXG2jbbYcRJN/IkIBKAjjxpNsZTaE8+ZM/rZC5xwT6B9W2GNlBOUxZc5fP GglknDumY6afpQsCGZhruiWsvQXy8zYn/DNOaIv64EqVaYr7x1NGXy1z6s2ZnhpJoFZi Db2RG0GEjMyzREljUGytITZSv9YCWZD9HIJAnQaVp8zLLXrm4MZO2z7KnRElcGwyGN0D ut1A== X-Gm-Message-State: AOJu0YxhfGrX3s+TNMKfpRSEF6/lkZ/JF4p3XPmpotngcJ13l8G8lxvr vPT9+c1Ylssml7xt9M24Q1oeoog2GQ0qME6kgAkgZ/vWvHDqTrASiESaz+Iw+2ux83bRfu6SD5C EXmRGHoJGoy1YPhARmFgt1Rc2HUqnbz2fi/ukyBwfneKDyQXxogX7T7P5QWv+y9qx5PA7uc+13j IgoS3eRe05e0LpBV2RnVVOlJeJQXSjMnKLX7o2 X-Google-Smtp-Source: AGHT+IGOIeOaCJokdUWxsKdM3W8tMcD8kS986lskqyEK3eyiSELwVShX7PIVcdLubRrrH16sEI0dsMF+NW3l X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:6902:120f:b0:dbe:d0a9:2be8 with SMTP id s15-20020a056902120f00b00dbed0a92be8mr81176ybu.0.1709072664329; Tue, 27 Feb 2024 14:24:24 -0800 (PST) Date: Tue, 27 Feb 2024 22:24:15 +0000 In-Reply-To: <20240227222417.929367-1-komlodi@google.com> Mime-Version: 1.0 References: <20240227222417.929367-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240227222417.929367-4-komlodi@google.com> Subject: [RFC PATCH 3/5] memattrs: Add user-defined attribute From: Joe Komlodi To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, peterx@redhat.com, david@redhat.com, peter.maydell@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, philmd@linaro.org, roqueh@google.com, slongfield@google.com, komlodi@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3GGHeZQcKCokx1zy1qvt11tyr.p1z3rz7-qr8ry010t07.14t@flex--komlodi.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org These are used to represent implementation-specific data. These are based off of AMBA-AXI user signals, but can be used in any implementation. The length of 4-bits is arbitrary. Signed-off-by: Joe Komlodi --- include/exec/memattrs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index 942b721be8..a38645f881 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -64,6 +64,8 @@ typedef struct MemTxAttrs { unsigned int target_tlb_bit0:1; unsigned int target_tlb_bit1:1; unsigned int target_tlb_bit2:1; + /* User-defined bits represent data that is implementation defined. */ + unsigned int user_defined:4; } MemTxAttrs; /* Bus masters which don't specify any attributes will get this, From patchwork Tue Feb 27 22:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Komlodi X-Patchwork-Id: 1905467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=4Zwq3uu2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TksWM0GDYz23qP for ; Wed, 28 Feb 2024 09:25:34 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf5sG-0006vM-KB; Tue, 27 Feb 2024 17:24:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3GmHeZQcKCosz3103sxv33v0t.r315t19-stAt0232v29.36v@flex--komlodi.bounces.google.com>) id 1rf5sE-0006tv-Dg for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:30 -0500 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3GmHeZQcKCosz3103sxv33v0t.r315t19-stAt0232v29.36v@flex--komlodi.bounces.google.com>) id 1rf5sC-0008Il-Q3 for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:30 -0500 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-608e4171382so37672347b3.3 for ; Tue, 27 Feb 2024 14:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709072666; x=1709677466; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3K58JDMdIZ5vfPmp+GaHPT46hd+lszOuP6OSMvo8Vsk=; b=4Zwq3uu2tLLt3TAYIDi5BbFDG9GIFuchXaQwZbrzJqoOpZ7Wkr/uwUp5xNsRkfp994 j0iar772xINVtBLlqZ46wZ6zb0OUV8WljEIMnYpa63cTol110Mf1u7Qccf3uzxLtm48u Jff9G/HGcZnmrePiHLMcWI7jfgxUVcL9rtu2xleyZVqMgnb3SRVQ970Q3HBFVuvUC6eo XwXJ+HqblXn1COsqkJkUJMRH37wBfmrAp7LrXS7ipLV3h2qsIC9R8ZaLPI0uCQKn7gDV pg325/+f5KjkoRkNNJ9xyp0p81qNeLDqUJxuuw0SjFsIxZ4mTuA9rYYY3XwFF2p1gno+ ZP/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709072666; x=1709677466; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3K58JDMdIZ5vfPmp+GaHPT46hd+lszOuP6OSMvo8Vsk=; b=MzJ8oIflHrmmuB+UlIeYI7EP608pOY8FTEtG5dD26aTOLgKeGQtp5A/DG/pdySurP9 xyVv3IVnQNbGYy0MCEF9lLlqpXJukyvAFuplRKN3NwLIfrPla7H5wbUlfQ9YqEKkhCc8 glENsVt01OouSkH6t/u5CYFmbblKXDc9s9FiFT5kMxWUpSeDg2kSPvOeyowqLUTM2vIz AHAhz6SrNXMgb8x4ZbIjv6jYsYDgVhWxPAJ1T5t1a9hLJbb1FgQY4VEbQ48X467umwgq BTK5OR+oBIQQqsZo8PFq8v9Zo9c4ROHfpB39y58I2UCW+I/VWTd1ypcfBKLaat29fNqn ltuQ== X-Gm-Message-State: AOJu0Yzv+h++MxBmRxjyfyhWg7QfxkNpEN9HvyEOLVcn4uU9USWr1+yx IGfFf2QrT8MB1LIBb0ko0D6RtmfVaiJe0SIGJ5LxNsTPB0GKJ+yzZVS3KEfofeHYe2gXnCi1lYK 6O/Ch1eQtsR+EV9kTGhb+nhCD7dgvTYXUMhATM/qRwBrlfvBCj5Me6OqXvkLXV/zJ2LmonjUTn5 Q5ii3FTnx7cqweOBiD0mEJo1Tgm+yG1UpilAJL X-Google-Smtp-Source: AGHT+IFNdzREnNQMu+UI/6N9TfbYHTjzbA2Vjf80uTnz63+iXNsR16qOg+vYWjDtj+EgdkUhTR3CRc9o4LT3 X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:6902:2106:b0:dc6:d1d7:d03e with SMTP id dk6-20020a056902210600b00dc6d1d7d03emr60797ybb.8.1709072666145; Tue, 27 Feb 2024 14:24:26 -0800 (PST) Date: Tue, 27 Feb 2024 22:24:16 +0000 In-Reply-To: <20240227222417.929367-1-komlodi@google.com> Mime-Version: 1.0 References: <20240227222417.929367-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240227222417.929367-5-komlodi@google.com> Subject: [RFC PATCH 4/5] target/arm: Add user-defined memattrs From: Joe Komlodi To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, peterx@redhat.com, david@redhat.com, peter.maydell@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, philmd@linaro.org, roqueh@google.com, slongfield@google.com, komlodi@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::114a; envelope-from=3GmHeZQcKCosz3103sxv33v0t.r315t19-stAt0232v29.36v@flex--komlodi.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org During transactions, these get added to memory attributes at the same time other attributes are added. Similar to the requester ID, these are added on PTWs, GPCs, and descriptor grabbing as well. Signed-off-by: Joe Komlodi --- target/arm/cpu.c | 2 ++ target/arm/cpu.h | 2 ++ target/arm/ptw.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 9cfbba10c2..dcd2c16c2e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2404,6 +2404,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) /* For MemTxAttrs. */ env->requester_id = cpu->requester_id; + env->memattr_user_defined = cpu->memattr_user_defined; qemu_init_vcpu(cs); cpu_reset(cs); @@ -2443,6 +2444,7 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), DEFINE_PROP_UINT16("requester-id", ARMCPU, requester_id, 0), + DEFINE_PROP_UINT8("memattr-user-defined", ARMCPU, memattr_user_defined, 0), DEFINE_PROP_END_OF_LIST() }; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5fc572e077..499a5b25c7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -777,6 +777,7 @@ typedef struct CPUArchState { /* For MemTxAttrs. */ uint16_t requester_id; + uint8_t memattr_user_defined; } CPUARMState; static inline void set_feature(CPUARMState *env, int feature) @@ -1097,6 +1098,7 @@ struct ArchCPU { /* Requester ID, used in MemTxAttrs. */ uint16_t requester_id; + uint8_t memattr_user_defined; }; typedef struct ARMCPUInfo { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 148af3a000..b2af3d9052 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -288,6 +288,7 @@ static bool granule_protection_check(CPUARMState *env, uint64_t paddress, .secure = true, .space = ARMSS_Root, .requester_id = env->requester_id, + .user_defined = env->memattr_user_defined, }; ARMCPU *cpu = env_archcpu(env); uint64_t gpccr = env->cp15.gpccr_el3; @@ -640,6 +641,7 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, .space = ptw->out_space, .secure = arm_space_is_secure(ptw->out_space), .requester_id = env->requester_id, + .user_defined = env->memattr_user_defined, }; AddressSpace *as = arm_addressspace(cs, attrs); MemTxResult result = MEMTX_OK; @@ -687,6 +689,7 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, .space = ptw->out_space, .secure = arm_space_is_secure(ptw->out_space), .requester_id = env->requester_id, + .user_defined = env->memattr_user_defined, }; AddressSpace *as = arm_addressspace(cs, attrs); MemTxResult result = MEMTX_OK; @@ -3310,6 +3313,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, result->f.attrs.secure = arm_space_is_secure(ptw->in_space); result->f.attrs.requester_id = env->requester_id; + result->f.attrs.user_defined = env->memattr_user_defined; switch (mmu_idx) { case ARMMMUIdx_Phys_S: From patchwork Tue Feb 27 22:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Komlodi X-Patchwork-Id: 1905466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=tqJSWTSE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TksWL6g9Lz23qG for ; Wed, 28 Feb 2024 09:25:34 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf5sG-0006vR-W4; Tue, 27 Feb 2024 17:24:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3G2HeZQcKCow04214tyw44w1u.s426u2A-tuBu1343w3A.47w@flex--komlodi.bounces.google.com>) id 1rf5sE-0006u8-Me for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:30 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3G2HeZQcKCow04214tyw44w1u.s426u2A-tuBu1343w3A.47w@flex--komlodi.bounces.google.com>) id 1rf5sD-0008JF-9H for qemu-devel@nongnu.org; Tue, 27 Feb 2024 17:24:30 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so8052068276.2 for ; Tue, 27 Feb 2024 14:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709072668; x=1709677468; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eqE7f5CT/axcKSnjnqXh+oEiq+xgWFDINsdVlLdZAO0=; b=tqJSWTSEBmxO9B9kVJfM/EjZcY57LNsaW4jcaBxv0gI03tviPLYY1Xh4iDv9p8RUZZ CQLlKfbQaaRs1f4OGN74Ow1L8vuHhvWyo4u2wiGIwvH9q3P9ff2QhwVDffa8m8wy3jxU ezxYnOQLH/X0epCCrJ/PJqx8ayK2msqLfnm0zs5iZgW/tEsV8jBO2prv83C4Uh+iwltZ d6QGVtyogkJvGW2qnM/R4Nc8QCTTMoMVMLvoTmVjRGJdaDXePLNssG+ss1MR5p27r6bO AB3r5ZTeVX58b6UW50dVtDPrcnBJvEZ+n606n0L5xR3D58L0cyBVUrv90qUPeU53GUzW q9Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709072668; x=1709677468; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eqE7f5CT/axcKSnjnqXh+oEiq+xgWFDINsdVlLdZAO0=; b=WQgdgwj5bE2C/Jm0aGpU7em44TdIpbXNbdCStGt0XL3Uezc5XsuJYCj/K/+yOF3y35 HP4mKEsZTytrhpNDGxltk5VgKzPSVGkinjM3lO1XlMY+zAJf2imC4a0tkVMxvf2jPzHU a6duwdGynsf7nG2Vc+hbleD94rHq54pe3G83Ud8l32CFvJiYpUEedHBMQUr9QHnSog7X WZshKs5DNbTm9kjURZrYQy9j2afmz/KA9wbmSMutnNWw/S2bmjEgnsrkrrlMaPVugzdZ dTsW+cQauukAqxW/ryf9Ob2paRlsnN6KH6zgGtmNerkNudN4Yo850g9d15m5GcbLKQIN BClQ== X-Gm-Message-State: AOJu0YyD56FS2+VDVRYsfkV+mYLiirRTGP01+FPWeN71dDTDHPsSU2zM Gnc2Wv12AmGhMv9+kGOsryzIl8H5s5vnVK3whNFmoJ3HYZGbJy48xzspTsdUcyYDsCjaW46Wg6O 4hgp1jansbyLaYDw2pVDulFeN3kzqT/Leb+egoxzNo1ZsxLJW0r9fhCZGUpmXOVM0DCbJ3VPoJe 0QN6Cx2oBPtJDRowcSy0uvHatyAWCRNzNCRCsW X-Google-Smtp-Source: AGHT+IGn8xeDtsxlzFfkZsipK7Q4BJjVVn30bQg6uNhnnTAJNNSV/H7eVfzag0aNkbEs1rdp8NFljlAxZfCo X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:6902:1896:b0:dcc:54d0:85e0 with SMTP id cj22-20020a056902189600b00dcc54d085e0mr213592ybb.11.1709072667824; Tue, 27 Feb 2024 14:24:27 -0800 (PST) Date: Tue, 27 Feb 2024 22:24:17 +0000 In-Reply-To: <20240227222417.929367-1-komlodi@google.com> Mime-Version: 1.0 References: <20240227222417.929367-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog Message-ID: <20240227222417.929367-6-komlodi@google.com> Subject: [RFC PATCH 5/5] hw/pci: Add user-defined memattrs From: Joe Komlodi To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, peterx@redhat.com, david@redhat.com, peter.maydell@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, philmd@linaro.org, roqueh@google.com, slongfield@google.com, komlodi@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3G2HeZQcKCow04214tyw44w1u.s426u2A-tuBu1343w3A.47w@flex--komlodi.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This adds user-defined bits, which users can set and use on transactions that involve memory attributes. We add it in the MSI function, since the attributes are initialized in that function. We do not add it in pci_dma_rw because the attributes are passed in. Some users might pass in MEMTXATTRS_UNSPECIFIED, and we should respect that instead of injecting user-defined attributes in the function. Signed-off-by: Joe Komlodi --- hw/pci/pci.c | 3 +++ include/hw/pci/pci_device.h | 1 + 2 files changed, 4 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 6496d027ca..b0bb682f15 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -85,6 +85,8 @@ static Property pci_props[] = { QEMU_PCIE_ERR_UNC_MASK_BITNR, true), DEFINE_PROP_BIT("x-pcie-ari-nextfn-1", PCIDevice, cap_present, QEMU_PCIE_ARI_NEXTFN_1_BITNR, false), + DEFINE_PROP_UINT8("memattr-user-defined", PCIDevice, memattr_user_defined, + 0), DEFINE_PROP_END_OF_LIST() }; @@ -361,6 +363,7 @@ static void pci_msi_trigger(PCIDevice *dev, MSIMessage msg) return; } attrs.requester_id = pci_requester_id(dev); + attrs.user_defined = dev->memattr_user_defined; address_space_stl_le(&dev->bus_master_as, msg.address, msg.data, attrs, NULL); } diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index d3dd0f64b2..99be6d72b1 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -84,6 +84,7 @@ struct PCIDevice { * conventional PCI root complex, this field is meaningless. */ PCIReqIDCache requester_id_cache; + uint8_t memattr_user_defined; char name[64]; PCIIORegion io_regions[PCI_NUM_REGIONS]; AddressSpace bus_master_as;