From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D6AD3CD13CF for ; Tue, 3 Sep 2024 08:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0x4pAN9v3PKcJSMJc9wNdVW/9mRtNQg8cuL1zQPTZck=; b=Q/33KxeWBGOgREzZhjjaQozxDc bFCNeEYzoTbVUV6Rzq3VzBv1ZAFCnru297Mb7o4T/vvmBIioxaBC0g6hcnkxl5sp7yxuoo0cxAcZJ bNB8p1C5DNddVhacTNt26cPOgTz3zB81gWf9iJ85MWuQD49haWZiA6an7CPfu6WgNp1GlKdFl5E8J QhuTDT1uGn8tJYmITSVtuSw1Nqf5Ar0dBL3bpBGNVLKfUB7CEgnI8wIBLiNOtxztpw6hgeYwctLvs 7JxBL6gR3dV21tBgVX0arL2gjdh4l/W5TVDXzr9IWjvB9QeJjK676MWBAeLGMq6h76Q4mGQfNyM5o 0/TyN/Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slP0T-0000000Gvby-01mg; Tue, 03 Sep 2024 08:35:21 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slOzX-0000000GvKU-353w for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 08:34:25 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5c24374d8b6so22118a12.1 for ; Tue, 03 Sep 2024 01:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725352462; x=1725957262; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=0x4pAN9v3PKcJSMJc9wNdVW/9mRtNQg8cuL1zQPTZck=; b=DCZYn8WZ/tAmIZ5+vqXWbEv7HRCAzNSRetTybLTjHbvAW2bIZy6uEsvpuf3qKfrRjT 0hqOg9AZ0pw2Y1p/kb/9AL4QumwstWcxS82OStcQ21+lWDts8X11TCDybLXeQxENKbU2 13RvBA1DKcdq3a0z1XH+jwlqMT2GqQ+wl1uEygeWnkJZ3hR4npj5ikU5geGobkMOrWZp tcsY+e9sajrMOR5NsBGeCUSBmQniLPSD0U1+iekhNg2WPeftZDfU1LYsJfXpyz7FHnOR b9fzq3LQLRDZfKHrfjb+bYpx2j+cWELkTg2dEIl1BFCLf3juOGKQ5pW9gpWIefC4DCJ6 xIIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725352462; x=1725957262; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0x4pAN9v3PKcJSMJc9wNdVW/9mRtNQg8cuL1zQPTZck=; b=V2zSuHZqMREA4b6FqTNzW3g/sA+ns3lNCC7Q8FsSqJ3TpZcvgWAvsUjTc4DVpkAHWW 72fwbROhOYgEQuHowLFwV5RJf6L02wA74xUTmVmM4vdfpu/v+ahNXqEeMc6ysWYLJOfr DFs2MHkrMJQGNJfmAbKcbF28d8ivkisnNIUaeJAKJ2vlGYpFT/mnEpjU4vElnQDvz9eH 1PoXChA4dHToTqP55TSuo+44RpoQsbiVrTKWIDkmKZe6Jk8aozhj201/xaBNMIQQkhk1 rVbb2e7VYxggpWKMja0FHUTkAi/8TMLNYh8IzVFMlQb2Nivl2kALJPZ/gslfIFrRtyjz 3ZKA== X-Forwarded-Encrypted: i=1; AJvYcCXw5v9GtqSrMHOZ8cwlUzWy98e7b7Qtc8CTxT0YIdYN2mZjjeqEuWc/Ebxuoow8mMl7xI0wumZmXmQDIxDJHjCi@lists.infradead.org X-Gm-Message-State: AOJu0YypaTMQ3yCrNFgTXujzcsFB+71PrblephZYowgFtpUZCSeEv9IY 12bC0iru4ZUD620pxK4oFZ4ojN8uNvBvj7DzVkVXFIDxQlhyF4kMbsUDHubzfg== X-Google-Smtp-Source: AGHT+IHojl3Oq9t0TVbNRBXWCRNq0mfrK+8JmhduosaFNh97XMJFm2HeZ0fHsdevV1+0F28pRpzQOw== X-Received: by 2002:a05:6402:2687:b0:5aa:19b1:ffc7 with SMTP id 4fb4d7f45d1cf-5c244360b96mr412535a12.2.1725352461558; Tue, 03 Sep 2024 01:34:21 -0700 (PDT) Received: from google.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374baae211bsm9667974f8f.66.2024.09.03.01.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 01:34:21 -0700 (PDT) Date: Tue, 3 Sep 2024 08:34:17 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: acpica-devel@lists.linux.dev, Hanjun Guo , iommu@lists.linux.dev, Joerg Roedel , Kevin Tian , kvm@vger.kernel.org, Len Brown , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi , "Rafael J. Wysocki" , Robert Moore , Robin Murphy , Sudeep Holla , Will Deacon , Alex Williamson , Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi Subject: Re: [PATCH v2 6/8] iommu/arm-smmu-v3: Support IOMMU_GET_HW_INFO via struct arm_smmu_hw_info Message-ID: References: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> <6-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> <20240830171602.GX3773488@nvidia.com> <20240903001654.GE3773488@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240903001654.GE3773488@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_013423_801293_942D91F1 X-CRM114-Status: GOOD ( 39.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 02, 2024 at 09:16:54PM -0300, Jason Gunthorpe wrote: > On Mon, Sep 02, 2024 at 10:11:16AM +0000, Mostafa Saleh wrote: > > > > What is the harm? Does exposing IDR data to userspace in any way > > > compromise the security or integrity of the system? > > > > > > I think no - how could it? > > > > I don’t see a clear harm or exploit with exposing IDRs, but IMHO we > > should deal with userspace with the least privilege principle and > > only expose what user space cares about (with sanitised IDRs or > > through another mechanism) > > If the information is harmless then why hide it? We expose all kinds > of stuff to userspace, like most of the PCI config space for > instance. I think we need a reason. > > Any sanitization in the kernel will complicate everything because we > will get it wrong. > > Let's not make things complicated without reasons. Intel and AMD are > exposing their IDR equivalents in this manner as well. > > > For example, KVM doesn’t allow reading reading the CPU system > > registers to know if SVE(or other features) is supported but hides > > that by a CAP in KVM_CHECK_EXTENSION > > Do you know why? > I am not really sure, but I believe it’s a useful abstraction > > > As the comments says, the VMM should not just blindly forward this to > > > a guest! > > > > I don't think the kernel should trust userspace. > > There is no trust. If the VMM blindly forwards the IDRS then the VMM > will find its VM's have issues. It is a functional bug, just as if the > VMM puts random garbage in its vIDRS. > > The onl purpose of this interface is to provide information about the > physical hardware to the VMM. > > > > The VMM needs to make its own IDR to reflect its own vSMMU > > > capabilities. It can refer to the kernel IDR if it needs to. > > > > > > So, if the kernel is going to limit it, what criteria would you > > > propose the kernel use? > > > > I agree that the VMM would create a virtual IDR for guest, but that > > doesn't have to be directly based on the physical one (same as CPU). > > No one said it should be. In fact the comment explicitly says not to > do that. > > The VMM is expected to read out of the physical IDR any information > that effects data structures that are under direct guest control. > > For instance anything that effects the CD on downwards. So page sizes, > IAS limits, etc etc etc. Anything that effects assigned invalidation > queues. Anything that impacts errata the VM needs to be aware of. > > If you sanitize it then you will hide information that someone will > need at some point, then we have go an unsanitize it, then add feature > flags.. It is a pain. I don’t have a very strong opinion to sanitise the IDRs (specifically many of those are documented anyway per IP), but at least we should have some clear requirement for what userspace needs, I am just concerned that userspace can misuse some of the features leading to a strange UAPI. Thanks, Mostafa > > Jason