From patchwork Fri Jun 21 20:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13708070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00678C2BB85 for ; Fri, 21 Jun 2024 20:58:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.745567.1152701 (Exim 4.92) (envelope-from ) id 1sKlKh-0005xn-MB; Fri, 21 Jun 2024 20:58:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 745567.1152701; Fri, 21 Jun 2024 20:58:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sKlKh-0005xg-JV; Fri, 21 Jun 2024 20:58:07 +0000 Received: by outflank-mailman (input) for mailman id 745567; Fri, 21 Jun 2024 20:58:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sKlKg-0005j1-Kg for xen-devel@lists.xenproject.org; Fri, 21 Jun 2024 20:58:06 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f465af9f-3010-11ef-b4bb-af5377834399; Fri, 21 Jun 2024 22:58:05 +0200 (CEST) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57cbc66a0a6so881006a12.1 for ; Fri, 21 Jun 2024 13:58:05 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d3042d509sm1440011a12.43.2024.06.21.13.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 13:58:03 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f465af9f-3010-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1719003484; x=1719608284; darn=lists.xenproject.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=bdyjt3BIACM8vTSuTSumyihaZrwR5nCq3lnnqbQTCh8=; b=vCXU0+Aj8Gi0FtsVdCZBEFM9KaYOmZ3INS1y/xw1aL+TbhhbRn+HpQ6padg6BnOzRa ECgw3J9/iWjCUTptnIo36x+uSpVEGXtnEXGWqXfEoXdln0YrBNd8N5Nb4ynNzVBev2ay 8IDBeC4jl7/Ce9OWEe6wmoCQbWq/TSEfhlaZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719003484; x=1719608284; 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=bdyjt3BIACM8vTSuTSumyihaZrwR5nCq3lnnqbQTCh8=; b=JZrSblH1OC+Sn6Xq7U53rTpY2x3ckALwQ0UmvzmDI1jLYZVnf7zKo/DIcWikC4uSoz dIFCIrEZPcF7LeMAGlGBamHcgMano3jaGi/FoFisyaYB60/6v0vuwVwMwRbvwERaBa6i jpwajJZQxM9HVoMJrV9BMrg+d/CHrfTpJ03dUp1rlolnf8AFlriwJP4jzsPDiwlknNUV Xfg9viubNxydMc/yqBSr3kbUjdCrai2OQQzHAm0AXIm44T5EU77QhiBEdTHUetqDiVas QibqleVDMYRs6IFV0qYbL9VT1zXLlnChcXusOgoLCKY+2YNPyOwA8IBn75Q0S2J/vfGs wDag== X-Gm-Message-State: AOJu0Yy7aNJZ1SShm8oABvEroOCp4blksKfOgXgRs2cSHWTjQwDnCfz7 xX2eQxtvjxhMLUuM1srIIDNCMhithtXMXyPRXo/XrKlM+vuwI5wrry/IlzgiW9Px/gQ3iYJN7SV oTwU= X-Google-Smtp-Source: AGHT+IGsGEoeFtjCEZAmgNF0aYxzTDgFROuk8KFeQVBo+qKImCPjmGqgL9fBnC3cLsT564i1CILIVw== X-Received: by 2002:aa7:db51:0:b0:57d:3df:ba2d with SMTP id 4fb4d7f45d1cf-57d3dff2a40mr540834a12.2.1719003483976; Fri, 21 Jun 2024 13:58:03 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Roberto Bagnara , "consulting @ bugseng . com" , Oleksii Kurochko Subject: [PATCH 1/2] x86/pagewalk: Address MISRA R8.3 violation in guest_walk_tables() Date: Fri, 21 Jun 2024 21:57:59 +0100 Message-Id: <20240621205800.329230-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240621205800.329230-1-andrew.cooper3@citrix.com> References: <20240621205800.329230-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Commit 4c5d78a10dc8 ("x86/pagewalk: Re-implement the pagetable walker") intentionally renamed guest_walk_tables()'s 'pfec' parameter to 'walk' because it's not a PageFault Error Code, despite the name of some of the constants passed in. Sadly the constants-cleanup I've been meaning to do since then still hasn't come to pass. Update the declaration to match, to placate MISRA. Fixes: 4c5d78a10dc8 ("x86/pagewalk: Re-implement the pagetable walker") Signed-off-by: Andrew Cooper Reviewed-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monné CC: Stefano Stabellini CC: Roberto Bagnara CC: consulting@bugseng.com CC: Oleksii Kurochko --- xen/arch/x86/include/asm/guest_pt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/guest_pt.h b/xen/arch/x86/include/asm/guest_pt.h index bc312343cdf1..7b0c9b005c1f 100644 --- a/xen/arch/x86/include/asm/guest_pt.h +++ b/xen/arch/x86/include/asm/guest_pt.h @@ -422,7 +422,7 @@ static inline unsigned int guest_walk_to_page_order(const walk_t *gw) bool guest_walk_tables(const struct vcpu *v, struct p2m_domain *p2m, - unsigned long va, walk_t *gw, uint32_t pfec, + unsigned long va, walk_t *gw, uint32_t walk, gfn_t top_gfn, mfn_t top_mfn, void *top_map); /* Pretty-print the contents of a guest-walk */ From patchwork Fri Jun 21 20:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13708072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9507C41513 for ; Fri, 21 Jun 2024 20:58:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.745568.1152712 (Exim 4.92) (envelope-from ) id 1sKlKi-0006CO-TY; Fri, 21 Jun 2024 20:58:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 745568.1152712; Fri, 21 Jun 2024 20:58:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sKlKi-0006CH-QV; Fri, 21 Jun 2024 20:58:08 +0000 Received: by outflank-mailman (input) for mailman id 745568; Fri, 21 Jun 2024 20:58:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sKlKh-0005sX-4d for xen-devel@lists.xenproject.org; Fri, 21 Jun 2024 20:58:07 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f4e44aba-3010-11ef-90a3-e314d9c70b13; Fri, 21 Jun 2024 22:58:05 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-57d1012e52fso2824908a12.3 for ; Fri, 21 Jun 2024 13:58:05 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d3042d509sm1440011a12.43.2024.06.21.13.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 13:58:04 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f4e44aba-3010-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1719003485; x=1719608285; darn=lists.xenproject.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=I2mJFKp0tzriHW0QjBAnMPOnFKVP/CBMSZnxZwykoKk=; b=uDbTKnDaxM9u7N8MNzOKHnnK5RT3+WGPicwdkXstY3AdUr1N9+Q2lq6xeDYf14V+OW 3aJIRJ3pf9TQUdaZPpVFBRqFTvoymOS5vmuov9i1xOlVsoMXbGe/OkmPgnT+HrcyfDnL w+67mHRFkLok+iZUNfyxjSX9LZc2f8mko3Z98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719003485; x=1719608285; 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=I2mJFKp0tzriHW0QjBAnMPOnFKVP/CBMSZnxZwykoKk=; b=mhkdFbN9NiXYHFsROuz9GdGEE5YWdqpzrx1u1i78mFHtyCsJ+deFcB3fwI8WIdD7uH 72q+61Y/9+WeI2O6wUVG9N51nm3+REICC8NHfhRuK6m0c2deOqQ4RK+K20mW0GWuZJbr iczMYtJQZnf+kXPPeTkoZqg3IOsTjz8vcb3UrHwgXMmRHECTUZnSofB+RRSauIYTRZxU hrXgvnhcwpY8rKtPd3WWxqqJB1wLr6XgxFJWoznWy4t+qayLmnOS5aHV/y76Hj299l1E 7qrvH4OzoUAIRbv9Rds5Tf5Px0InX2Zb8GRy1zSuZ4Kf4CnUhC+KpzeMUf0w3meWHMXK xfcQ== X-Gm-Message-State: AOJu0Yy+YukvQJETRALvRtrqbKOIVDNS6ETVzGoRARTtWFT4XlzehQ+g Wfnk6FqL11XdCgjkGJ+OJqPiblb3+bIvKR1ZaC3+Af7i5p6T9oVLoi/8btOkzQkW63+zqHhGf0B c8/w= X-Google-Smtp-Source: AGHT+IFXHPD0wWta+oxEYQcmgEfPdVSHm0Vxn7VWpzd99ufMFqO8UaVmn6TUdSvAMxiUnh9lEus+8w== X-Received: by 2002:a50:d50a:0:b0:57d:2716:838c with SMTP id 4fb4d7f45d1cf-57d27168510mr3030952a12.37.1719003485207; Fri, 21 Jun 2024 13:58:05 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Roberto Bagnara , "consulting @ bugseng . com" , Oleksii Kurochko Subject: [PATCH 2/2] xen/multicall: Change nr_calls to uniformly be unsigned long Date: Fri, 21 Jun 2024 21:58:00 +0100 Message-Id: <20240621205800.329230-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240621205800.329230-1-andrew.cooper3@citrix.com> References: <20240621205800.329230-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Right now, the non-compat declaration and definition of do_multicall() differing types for the nr_calls parameter. This is a MISRA rule 8.3 violation, but it's also time-bomb waiting for the first 128bit architecture (RISC-V looks as if it might get there first). Worse, the type chosen here has a side effect of truncating the guest parameter, because Xen still doesn't have a clean hypercall ABI definition. Switch uniformly to using unsigned long. This addresses the MISRA violation, and while it is a guest-visible ABI change, it's only in the corner case where the guest kernel passed a bogus-but-correct-when-truncated value. I can't find any any users of mutilcall which pass a bad size to begin with, so this should have no practical effect on guests. In fact, this brings the behaviour of multicalls more in line with the header description of how it behaves. With this fix, Xen is now fully clean to Rule 8.3, so mark it so. Signed-off-by: Andrew Cooper Reviewed-by: Stefano Stabellini --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Julien Grall CC: Roger Pau Monné CC: Stefano Stabellini CC: Roberto Bagnara CC: consulting@bugseng.com CC: Oleksii Kurochko I know this isn't going to be universally liked, but we need to do something, and this is my very strong vote for the least bad way out of the current mess. --- automation/eclair_analysis/ECLAIR/tagging.ecl | 1 + xen/common/multicall.c | 4 ++-- xen/include/hypercall-defs.c | 4 ++-- xen/include/public/xen.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/automation/eclair_analysis/ECLAIR/tagging.ecl b/automation/eclair_analysis/ECLAIR/tagging.ecl index b829655ca0bc..3d06a1aad410 100644 --- a/automation/eclair_analysis/ECLAIR/tagging.ecl +++ b/automation/eclair_analysis/ECLAIR/tagging.ecl @@ -45,6 +45,7 @@ MC3R1.R7.2|| MC3R1.R7.4|| MC3R1.R8.1|| MC3R1.R8.2|| +MC3R1.R8.3|| MC3R1.R8.5|| MC3R1.R8.6|| MC3R1.R8.8|| diff --git a/xen/common/multicall.c b/xen/common/multicall.c index 1f0cc4cb267c..ce394c5efcfe 100644 --- a/xen/common/multicall.c +++ b/xen/common/multicall.c @@ -34,11 +34,11 @@ static void trace_multicall_call(multicall_entry_t *call) } ret_t do_multicall( - XEN_GUEST_HANDLE_PARAM(multicall_entry_t) call_list, uint32_t nr_calls) + XEN_GUEST_HANDLE_PARAM(multicall_entry_t) call_list, unsigned long nr_calls) { struct vcpu *curr = current; struct mc_state *mcs = &curr->mc_state; - uint32_t i; + unsigned long i; int rc = 0; enum mc_disposition disp = mc_continue; diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c index 47c093acc84d..7720a29ade0b 100644 --- a/xen/include/hypercall-defs.c +++ b/xen/include/hypercall-defs.c @@ -135,7 +135,7 @@ xenoprof_op(int op, void *arg) #ifdef CONFIG_COMPAT prefix: compat set_timer_op(uint32_t lo, uint32_t hi) -multicall(multicall_entry_compat_t *call_list, uint32_t nr_calls) +multicall(multicall_entry_compat_t *call_list, unsigned long nr_calls) memory_op(unsigned int cmd, void *arg) #ifdef CONFIG_IOREQ_SERVER dm_op(domid_t domid, unsigned int nr_bufs, void *bufs) @@ -172,7 +172,7 @@ console_io(unsigned int cmd, unsigned int count, char *buffer) vm_assist(unsigned int cmd, unsigned int type) event_channel_op(int cmd, void *arg) mmuext_op(mmuext_op_t *uops, unsigned int count, unsigned int *pdone, unsigned int foreigndom) -multicall(multicall_entry_t *call_list, unsigned int nr_calls) +multicall(multicall_entry_t *call_list, unsigned long nr_calls) #ifdef CONFIG_PV mmu_update(mmu_update_t *ureqs, unsigned int count, unsigned int *pdone, unsigned int foreigndom) stack_switch(unsigned long ss, unsigned long esp) diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index b47d48d0e2d6..e051f989a5ca 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -623,7 +623,7 @@ DEFINE_XEN_GUEST_HANDLE(mmu_update_t); /* * ` enum neg_errnoval * ` HYPERVISOR_multicall(multicall_entry_t call_list[], - * ` uint32_t nr_calls); + * ` unsigned long nr_calls); * * NB. The fields are logically the natural register size for this * architecture. In cases where xen_ulong_t is larger than this then