From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.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 89C13371043 for ; Mon, 11 May 2026 11:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.160.176 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778500430; cv=pass; b=UO0NLB+ZY6mPW0SJKNpdgzc5AfYvspyCC80/tWBsCEUlmW3lbdesdFkXxqTweb7XcWbS0WwkGzSRmb/bmGWITbONiRNmBvDS9cP7szNJhxNzjlS39Ijp9qXCEG8L/aPRJEd5uUTN4YIPi7j2Zeoc8ZumHQCqfK5hqdY0WNLRZCk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778500430; c=relaxed/simple; bh=EyEdGT/UwThY07rJVuH5QIYg5WfjYK/VMng0MYb/gWQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AQ1pxDJCgDGWievzXn92E+Jj4V4vL7/PZBnMEBEJo/SXWS9yzo0O1rTeswQdWBMSB5fxscUnqHdwCp3J96+LS7nXELo04FASyYT/bP9QhHNiYf+0IqyrhFzuKutggfFDkZCrvZrG1fOjBjQcXN8AEn+MlkIrY9Yod+w1ifYeRvQ= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cuGlXdNt; arc=pass smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cuGlXdNt" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-50d836552daso1231cf.0 for ; Mon, 11 May 2026 04:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778500428; cv=none; d=google.com; s=arc-20240605; b=BduR5QpQ13Z3u7I2kRIv4kfFW/RvKOf8JCFoDuoEdaE2E9HqE4n3KW/RFgPBfdls2S 0gAQlSci1U3jw2kHHApPqqScchukaPNlFvZJ548pggP/tkaOSI8E+OtlPn0/pMGh9s2f 9qoUFYRyVXUMEbmPHB7ocvV5FUCmMGFOn057ZlQJrWCmYtTUuaHt9tUJtInhRDrUUU10 UDdyr3KhYId2raJO+LFmNoRT7TdxFKgej8pVUHLTJob2oVaBGYDLwLuXDBtMX4W0esaV fTu6k40lAQEakmBXdByc+JtdWr1q9tvG362k3I+9TO794DDjQoQAJ7z7yJeBcl2MVR5o jsiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EyEdGT/UwThY07rJVuH5QIYg5WfjYK/VMng0MYb/gWQ=; fh=BzI5HzKph1Hel6dUkFXyMZw8TJNh1WamnoAuKwaZNZg=; b=cKPCBAymB/lWE4acvz17NNxguB9gb9wGnIaEQ4UK59m9hn5OWQDoc708YCRoyFHlMv ZWid7kerP+TJ2LyDST/gXg8GOPa0Y7tXmHwpBpaAS9bboje4vb5GRNNBFPfjf4kFwWnK 5a36SE7AvKcbFNw18sd1UrxR2EADBhj6+pVlHe4YGblQpGAujhzUm3KsabBrurrSOCWu yg1KeA0VXH+sGwOwbk1e5RIZmE3WcsVitRVO4HgSr1jbMrsMYdtuwz9pKiLjTT2Xci/q 2hcb/wtLIkDra+UrIlI573qpZNWbtq8GUJ1FKKy+8cOwKBso7kxc4CI0r01payURNuki fXSw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778500428; x=1779105228; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EyEdGT/UwThY07rJVuH5QIYg5WfjYK/VMng0MYb/gWQ=; b=cuGlXdNtxClQiTDppYsDFgcXTkdowdUaIRJUJsTmTLrjNGCf0jvguLyK9ClacvA52i b28PeYgqyZPsVjDC3pG2+uC5ZzEeRlZ7XZy1pxqjr5BQEJUAoiFfYv/6Zh+uRbh0kpVJ A5Zmz5luGxZsvslx9Gm1z4LiUS4NMWshR5WRi2u/H8ytSdvcVMtpcpvFQtl+CwCHx5dd XouxRxN7iiKrDIw/WoVKGnXy2nMVaxtbsP/5YnAcfv23rpU6xaWAQ5MpzMZ999D4Mqkh /jO8qDwPwX6Qd2KmidkNhzgWQ1HLAQvAw4G6Dk1Hhesu1bUvhXCE1LXI3DXjHVp00/GN KkaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778500428; x=1779105228; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EyEdGT/UwThY07rJVuH5QIYg5WfjYK/VMng0MYb/gWQ=; b=opGrzyBtKH0/FmDJmASRxKlyiwjcDsxycKRfQq+uPsV4Q//4jE4b6hTCvFo0J2pfUC oJ8N/0vlfXYObYSYGzn5q+HA3tdlxsC2/OVQroA43gpXw3HyyABjZ7ZZ8O/4ZgPfArMZ PM4qv/YDc1SefmxkMZeMkp8kJv6+jSeSMdnKObHKQ4JFpiJuFbfwovmje6B+kg6B4KUx iV0zmpydJnBDTAxH67mBBduU3ZAl0CV9q/olB2UfFiM2GeiLxSzTPKkFAIhaboZEt7RF U+m1yofYvCcioJ1VCsCYH17ThI7L3+sO87dDydoFaKQd7gCARuTfun3sp90dAj+3lL3V /caQ== X-Forwarded-Encrypted: i=1; AFNElJ9pWKXExfdFmRaKoiQcS19nqcnuusD4FpgkPIBVnfHKviGIMNxZa5OAfw16pIXQSYwWrbkKfj3+o+kb+bc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7DOh9EgNtqIAm6Pz+iBOyvHbDPbl69C+ygl/mwz38tmbdEK44 0+6aIvM8u6NhX8ow/iTXj4ztKpQoLsOFZPuP7Uu0yXW9SjCM3MOUnhkWMVGDCkfG8Mj3o1v609B JQZgEKuB5PLKTtrmhC5R1q92DZn6eIDLuuFNp8D8r X-Gm-Gg: Acq92OHrgTXRVV2u+slIdOOFGUhUNYccapCSM12jyfenIkWCd/fLkG73d3ulEbcinrs 0GdWXCzbYYGbm6rMt3soIgPtTexSwi7qRxCvwA5RkGz4T0gV5Lft5hqyV9gj4/lTeIqhxEB9HK6 bSxZ7DrsgwBO9xFUGR9AlhpWoPnkp0SNRJ8LqtG4evHdiuQHQcBn8YLSVUBklx6Nf1rhMxx755H 9sluEuCQyYO1GU+L64kOTkH0Y/xP4eae46ePviH2SVZp47z9ca2aD3XnCLRbOzGoEXmI89IhKAj X+CW46BAPlTM6dGKcxqUC2nYDNhEoAMdfMtjiWi7w4Tc/nT1nuTcWg6y1FXNcQ== X-Received: by 2002:a05:622a:8d12:b0:50e:5c9d:49c7 with SMTP id d75a77b69052e-514a046fbc9mr19494131cf.7.1778500427992; Mon, 11 May 2026 04:53:47 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260501111928.259252-1-smostafa@google.com> <20260501111928.259252-6-smostafa@google.com> <20260501124716.GD6912@ziepe.ca> <20260509233443.GK9285@ziepe.ca> In-Reply-To: <20260509233443.GK9285@ziepe.ca> From: Mostafa Saleh Date: Mon, 11 May 2026 12:53:36 +0100 X-Gm-Features: AVHnY4Iy01SZKx6-ZKVz0uRzPgk9VsXyMheNVJnPIgQawwYuBaPqoPjvouiwCBk Message-ID: Subject: Re: [PATCH v6 05/25] iommu/arm-smmu-v3: Move IDR parsing to common functions To: Jason Gunthorpe Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, joro@8bytes.org, jean-philippe@linaro.org, mark.rutland@arm.com, qperret@google.com, tabba@google.com, vdonnefort@google.com, sebastianene@google.com, keirf@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, May 10, 2026 at 12:34=E2=80=AFAM Jason Gunthorpe wro= te: > > On Thu, May 07, 2026 at 10:13:13AM +0000, Mostafa Saleh wrote: > > > I was thinking more like > > > > > > #define arm_smmu arm_pkvm_smmu > > > > > > Before the pkvm compile of the shared code. > > > > Oh, so we rely on arm_pkvm_smmu and arm_smmu having the same field > > names and types? > > Just for the shared code, yes. > > For instance this patch would require the features field be present in > both, and then all you do is directly copy all the smmu->features > logic into the shared file and that's it. > > > I don=E2=80=99t think that=E2=80=99s better for maintainability, I can = look into it > > if Robin and Will are OK with that. > > I think maintainability here means pkvm minimizes how much it changes > the code of the main driver. > > Copying a bunch of functions into a shared .c file exactly as it is, > then compiling the shared file with some #ifdef'ery at is going to be > long term better than trying to mangle the whole thing to avoid using > any of the core types and not directly share the code, IMHO. > There isn't #ifdef'ery at the moment, that's what I was trying to avoid by introducing shared code. I believe that can be treated as a library as most of the shared code is about HW description (commands, invalidation, IDR probing...) > Like my tlbi point for instance, it is not a good idea to rip out a > little bit of the invalidation logic then open code a pkvm > version. Use the exact driver code. But to do this you need to pass an > arm_smmu through to to the pkvm specific queue management functions. > What concerns me is how fragile that is, any change in the main struct can easily break the hypervisor, unlike if we have a clear shared code and defined API that is used by 2 entities. I will think more about this before v7 and see how intrusive it is. > > > How does pkvm compilation work anyhow? Is it all rolled into a unique > > > link, or do you have to worry about symbol conflicts with the main > > > kernel? > > > > All pkvm symbols are prefixed with __kvm_nvhe_ in the main kernel. > > So automatically with objcopy or something like that during the build? > Exactly: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= /tree/arch/arm64/kvm/hyp/nvhe/Makefile#n96 Thanks, Mostafa > Jason