From nobody Tue Nov 26 08:41:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709107729; cv=none; d=zohomail.com; s=zohoarc; b=H6tGQCyQ7tihXg0K9fSF2CrzzvXyfamI8GtMxI0gQe+J1zLa3L974M0ii/q1ixVr56/k5pBRmVJIBmwGHtc6Ynb8HuRDwOlX7CTSUmRqzAU42yZObaKV32++0AUricrZ/oSt3AQLfEOIXVZI74zuliQHKLV2XANBuoL3rxYOUYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709107729; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=oaaGnvOvuEg+amyykEvtj5XWm41K6EEY0fV7AH7s47U=; b=A7dINo7kOAMMMLPcq7GFi//HMO89gkCST93PyaYuiQkbeu3oVTrYBS/VlgDyCvnWizExLXNEU5YZUTeB80bPU6VgV9KjJMEXCGBcrKuAUnzW3PvmLvHZJiGjJskzgFE2MR4IsntJeaikLQrOMnx4HyPFgFMa7tw3DIsnrLEN9F8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709107729641775.8388405562066; Wed, 28 Feb 2024 00:08:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfEyK-0001W0-8z; Wed, 28 Feb 2024 03:07:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfEyJ-0001Vk-MK for qemu-devel@nongnu.org; Wed, 28 Feb 2024 03:07:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfEyA-0000W1-Jc for qemu-devel@nongnu.org; Wed, 28 Feb 2024 03:07:23 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73-yzQfujq3PdSkvfP4B65j-w-1; Wed, 28 Feb 2024 03:07:12 -0500 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3e94bbb22dso367048866b.1 for ; Wed, 28 Feb 2024 00:07:11 -0800 (PST) Received: from [192.168.10.118] ([93.56.170.180]) by smtp.gmail.com with ESMTPSA id a5-20020a170906468500b00a3fb4d11809sm1581168ejr.204.2024.02.28.00.07.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709107633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oaaGnvOvuEg+amyykEvtj5XWm41K6EEY0fV7AH7s47U=; b=YoiR+JpG1S8suB6FmGh+STBI0dKCecZHB6PMCvYpR9bX711nVHnSn8hNxoJ+bi9d+HSOI1 vCwmKCbsCh0gGOAFO6vuAglxK2300pW5n/sAcuScNMYtZB/M1l14eSwnK19BQ+/+cG5c7x g+Zb8LgdtKN92TnKya5YZ8gPKfw+ZO8= X-MC-Unique: yzQfujq3PdSkvfP4B65j-w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709107630; x=1709712430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oaaGnvOvuEg+amyykEvtj5XWm41K6EEY0fV7AH7s47U=; b=MHrINMftzJAsD9p2s57DKkyFVXDnJEKIRvYXrSelA9yMsMs9Sp2Gq5eOwW28eaJrzp nwM+nzarfFBC4HKJ/i9phoQrUrHnC/R+GXOrsQ8Q0R15Alyuw7pDoTJT0kPAkXgFCaee xB4mheFkM5f6L07XRPR87tb4tGbVi8bkDk5pxB8GIvZa2PjVLWV1kV2cOkFajeI4CEb+ Yx90AW1bV6Ns060f1+YTyCRPepWD6KqvO/C6O0XP3AkzazKNrWaMc2PfaZDstYG2EjSE IiDTibuuwX/8AMhBADWwsKmiNjw72xsR9KUJxwg1Im5BmqQbEi92fukQ8JsQWdMKDYkU K2dQ== X-Gm-Message-State: AOJu0Ywnak1GTam0Y9Yf1MNVl/nHZp9zvHYrFYVeRAjHhtOTTMCESZwk 8RgRUyrDWE817oWjmuM0C9Ccn0yUl672bDPRzWQoLVMdOTuEezFpTx0zEiYM2Bh+O3pUAR64DF6 Loqpf+AOqBX08DzBk9VScCTeUJShT0NZJvXbpJazGfcyYOasVh+r2RRf1uwFIrNzJCCXrqMAVCk mmXJu8tL4xY5x2JeNb6pPJo06sVq7I0kzKFafX X-Received: by 2002:a17:906:69b:b0:a42:f3a6:9f7f with SMTP id u27-20020a170906069b00b00a42f3a69f7fmr7114876ejb.13.1709107630209; Wed, 28 Feb 2024 00:07:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSWHdk1bKJAGaPUAIqnmIiQGzY6CZeVMpweNzhyKOnG/9IKuQCDv1QWCENqS6lIHrjJi+C9g== X-Received: by 2002:a17:906:69b:b0:a42:f3a6:9f7f with SMTP id u27-20020a170906069b00b00a42f3a69f7fmr7114851ejb.13.1709107629729; Wed, 28 Feb 2024 00:07:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/10] target/i386: introduce function to query MMU indices Date: Wed, 28 Feb 2024 09:06:40 +0100 Message-ID: <20240228080646.261365-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228080646.261365-1-pbonzini@redhat.com> References: <20240228080646.261365-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709107730623100009 Content-Type: text/plain; charset="utf-8" Remove knowledge of specific MMU indexes (other than MMU_NESTED_IDX and MMU_PHYS_IDX) from mmu_translate(). This will make it possible to split 32-bit and 64-bit MMU indexes. Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 10 ++++++++++ target/i386/tcg/sysemu/excp_helper.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index dfe43b82042..8c271ca62e5 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2305,6 +2305,16 @@ uint64_t cpu_get_tsc(CPUX86State *env); #define MMU_NESTED_IDX 3 #define MMU_PHYS_IDX 4 =20 +static inline bool is_mmu_index_smap(int mmu_index) +{ + return mmu_index =3D=3D MMU_KSMAP_IDX; +} + +static inline bool is_mmu_index_user(int mmu_index) +{ + return mmu_index =3D=3D MMU_USER_IDX; +} + static inline int cpu_mmu_index_kernel(CPUX86State *env) { return !(env->hflags & HF_SMAP_MASK) ? MMU_KNOSMAP_IDX : diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/= excp_helper.c index 11126c860d4..a0d5ce39300 100644 --- a/target/i386/tcg/sysemu/excp_helper.c +++ b/target/i386/tcg/sysemu/excp_helper.c @@ -137,7 +137,7 @@ static bool mmu_translate(CPUX86State *env, const Trans= lateParams *in, const int32_t a20_mask =3D x86_get_a20_mask(env); const target_ulong addr =3D in->addr; const int pg_mode =3D in->pg_mode; - const bool is_user =3D (in->mmu_idx =3D=3D MMU_USER_IDX); + const bool is_user =3D is_mmu_index_user(in->mmu_idx); const MMUAccessType access_type =3D in->access_type; uint64_t ptep, pte, rsvd_mask; PTETranslate pte_trans =3D { @@ -363,7 +363,7 @@ do_check_protect_pse36: } =20 int prot =3D 0; - if (in->mmu_idx !=3D MMU_KSMAP_IDX || !(ptep & PG_USER_MASK)) { + if (!is_mmu_index_smap(in->mmu_idx) || !(ptep & PG_USER_MASK)) { prot |=3D PAGE_READ; if ((ptep & PG_RW_MASK) || !(is_user || (pg_mode & PG_MODE_WP))) { prot |=3D PAGE_WRITE; --=20 2.43.2