Re: [PATCH v3 2/2] x86/sgx: Implement EUPDATESVN and opportunistically call it during first EPC page alloc

2025-04-29 Thread Dave Hansen
On 4/29/25 04:44, Reshetova, Elena wrote: >> On 4/25/25 14:58, Sean Christopherson wrote: >>> On Fri, Apr 25, 2025, Dave Hansen wrote: >>>> On 4/25/25 14:04, Sean Christopherson wrote: >>>>> Userspace is going to be waiting on ->release() no matter wh

Re: [PATCH v3 2/2] x86/sgx: Implement EUPDATESVN and opportunistically call it during first EPC page alloc

2025-04-25 Thread Dave Hansen
On 4/25/25 14:58, Sean Christopherson wrote: > On Fri, Apr 25, 2025, Dave Hansen wrote: >> On 4/25/25 14:04, Sean Christopherson wrote: >>> Userspace is going to be waiting on ->release() no matter what. >> Unless it isn't even involved and it happens automatica

Re: [PATCH v3 2/2] x86/sgx: Implement EUPDATESVN and opportunistically call it during first EPC page alloc

2025-04-25 Thread Dave Hansen
On 4/25/25 14:04, Sean Christopherson wrote: > Userspace is going to be waiting on ->release() no matter what. Unless it isn't even involved and it happens automatically.

Re: [PATCH v3 2/2] x86/sgx: Implement EUPDATESVN and opportunistically call it during first EPC page alloc

2025-04-25 Thread Dave Hansen
On 4/25/25 12:29, Sean Christopherson wrote: > --- a/arch/x86/kernel/cpu/sgx/virt.c > +++ b/arch/x86/kernel/cpu/sgx/virt.c > @@ -255,6 +255,7 @@ static int sgx_vepc_release(struct inode *inode, struct > file *file) > xa_destroy(&vepc->page_array); > kfree(vepc); > > + sgx_dec_usa

Re: [PATCH v3 2/2] x86/sgx: Implement EUPDATESVN and opportunistically call it during first EPC page alloc

2025-04-25 Thread Dave Hansen
On 4/25/25 10:40, Sean Christopherson wrote: > So then why on earth is the kernel implementing automatic updates? Because it's literally the least amount of code and doesn't create any new ABI. > I read back through most of the cover letters, and IIUC, we went > straight from "destroy all enclave

Re: [PATCH] selftests/sgx: Fix an enclave built with extended instructions

2025-04-09 Thread Dave Hansen
On 4/9/25 09:55, Vladis Dronov wrote: ... > Fix this by adding "-mno-avx" to ENCL_CFLAGS in Makefile. Add some comments > about this to code locations where enclave's xfrm field is set. > > Suggested-by: Dave Hansen > Signed-off-by: Vladis Dronov First of all, th

Re: [PATCH] arch/x86: Fix size overflows in sgx_encl_create()

2025-03-04 Thread Dave Hansen
On 3/4/25 14:56, Jarkko Sakkinen wrote: > The total size calculated for EPC can overflow u64 given the added up page > for SECS. Further, the total size calculated for shmem can overflow even > when the EPC size stays within limits of u64, given that it adds the extra > space for 128 byte PCMD str

Re: [PATCH V5 2/4] x86/tdx: Route safe halt execution via tdx_safe_halt()

2025-02-20 Thread Dave Hansen
On 2/20/25 13:16, Vishal Annapurve wrote: > Direct HLT instruction execution causes #VEs for TDX VMs which is routed > to hypervisor via TDCALL. safe_halt() routines execute HLT in STI-shadow > so IRQs need to remain disabled until the TDCALL to ensure that pending > IRQs are correctly treated as w

Re: [PATCH V5 1/4] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT

2025-02-20 Thread Dave Hansen
On 2/20/25 13:16, Vishal Annapurve wrote: > Since enabling CONFIG_PARAVIRT_XXL is too bloated for TDX guest > like platforms, move HLT and SAFE_HLT paravirt calls under > CONFIG_PARAVIRT. I guess it's just one patch, but doesn't this expose CONFIG_PARAVIRT=y users to what _was_ specific to CONFIG_

Re: [PATCH v2 6/6] selftests/mm: remove local __NR_* definitions

2025-02-13 Thread Dave Hansen
On 2/13/25 00:04, John Hubbard wrote: > > 2) I'm unable to reproduce what you saw, because in ALL cases (before > or after the commit, and with or without a revert), I get the same > results on my Intel test machine: > >     $ ./protection_keys_64 >     has pkeys: 0 >     running PKEY tests for u

Re: [PATCH v2 6/6] selftests/mm: remove local __NR_* definitions

2025-02-12 Thread Dave Hansen
Hi John, On 6/13/24 19:30, John Hubbard wrote: > --- a/tools/testing/selftests/mm/protection_keys.c > +++ b/tools/testing/selftests/mm/protection_keys.c > @@ -42,7 +42,7 @@ > #include > #include > #include > -#include > +#include > #include > #include I'm not quite sure how but this b

Re: [PATCH] x86: sgx: Don't track poisoned pages for reclaiming

2025-02-11 Thread Dave Hansen
On 2/11/25 16:32, andrzej zaborowski wrote: >> Actually, now that I think about it even more, why would ETRACK or >> EBLOCK access the page itself? They seem superficially like they'd be >> metadata-only too. > I haven't seen a crash in either of these (always in EWB), I didn't > want to imply that

Re: [PATCH] x86: sgx: Don't track poisoned pages for reclaiming

2025-02-11 Thread Dave Hansen
On 2/11/25 13:18, Huang, Kai wrote: >>> This requires low-level SGX implementation knowledge to fully >>> understand. Both what "ETRACK, EBLOCK and EWB" are in the first place, >>> how they are involved in reclaim and also why EREMOVE doesn't lead to >>> the same fate. >> >> Does it? [I'll dig up I

Re: [PATCH] x86: sgx: Don't track poisoned pages for reclaiming

2025-02-11 Thread Dave Hansen
I don't expect everyone to know the rules of every little part of the kernel. But, it's really easy to see a pattern with: git log arch/x86/kernel/cpu/sgx/ That usually works for every little nook and cranny of the kernel and will show you what the subject rules are. Could you do that fo

Re: [PATCH v5 1/3] selftests/lam: Move cpu_has_la57() to use cpuinfo flag

2025-01-24 Thread Dave Hansen
On 1/24/25 12:17, Maciej Wieczor-Retman wrote: >> Could you poke around and see if there is any existing ABI that we can >> use to query LA57 support? Maybe one of the things KVM exports, or some >> TASK_SIZE_MAX comparisons? > Sure, I'll try to find some other way. > > My previous tactic was to m

Re: [PATCH v5 3/3] selftests/lam: Test get_user() LAM pointer handling

2025-01-24 Thread Dave Hansen
On 11/27/24 09:35, Maciej Wieczor-Retman wrote: ... > + switch (test->later) { > + case GET_USER_USER: > + /* Control group - properly tagger user pointer */ > + ptr = (void *)set_metadata((uint64_t)ptr, test->lam); > + break; s/tagger/tagged/ ? > +

Re: [PATCH v5 2/3] selftests/lam: Skip test if LAM is disabled

2025-01-24 Thread Dave Hansen
On 11/27/24 09:35, Maciej Wieczor-Retman wrote: > +static inline int kernel_has_lam(void) > +{ > + unsigned long bits; > + > + syscall(SYS_arch_prctl, ARCH_GET_MAX_TAG_BITS, &bits); > + return !!bits; > +} Generally, I'm less picky about selftest/ code than in-kernel code. But people r

Re: [PATCH v5 1/3] selftests/lam: Move cpu_has_la57() to use cpuinfo flag

2025-01-24 Thread Dave Hansen
On 11/27/24 09:35, Maciej Wieczor-Retman wrote: > -/* Check 5-level page table feature in CPUID.(EAX=07H, ECX=00H):ECX.[bit 16] > */ > static inline int cpu_has_la57(void) > { > - unsigned int cpuinfo[4]; > - > - __cpuid_count(0x7, 0, cpuinfo[0], cpuinfo[1], cpuinfo[2], cpuinfo[3]); > -

Re: [PATCH] acpi: nfit: fix narrowing conversion in acpi_nfit_ctl

2025-01-23 Thread Dave Jiang
On 1/23/25 9:39 AM, Murad Masimov wrote: > Syzkaller has reported a warning in to_nfit_bus_uuid(): "only secondary > bus families can be translated". This warning is emited if the argument > is equal to NVDIMM_BUS_FAMILY_NFIT == 0. Function acpi_nfit_ctl() first > verifies that a user-provided v

Re: [PATCH v6] acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl

2024-12-02 Thread Dave Jiang
ved2 array. > > Reported-by: syzbot+7534f060ebda6b8b5...@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=7534f060ebda6b8b51b3 > Tested-by: syzbot+7534f060ebda6b8b5...@syzkaller.appspotmail.com > Fixes: ebe9f6f19d80 ("acpi/nfit: Fix bus command validation") &

Re: [PATCH v4] acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl

2024-11-15 Thread Dave Jiang
ved2 array. > > Reported-by: syzbot+7534f060ebda6b8b5...@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=7534f060ebda6b8b51b3 > Tested-by: syzbot+7534f060ebda6b8b5...@syzkaller.appspotmail.com > Fixes: ebe9f6f19d80 ("acpi/nfit: Fix bus command validation") &

Re: [PATCH v3] acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl

2024-11-14 Thread Dave Jiang
On 11/14/24 2:19 AM, Suraj Sonawane wrote: > On 13/11/24 22:32, Dave Jiang wrote: >> >> >> On 11/13/24 5:51 AM, Suraj Sonawane wrote: >>> Fix an issue detected by syzbot with KASAN: >>> >>> BUG: KASAN: vmalloc-out-of-bounds in cmd_to_func dr

Re: [PATCH v3] acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl

2024-11-13 Thread Dave Jiang
On 11/13/24 5:51 AM, Suraj Sonawane wrote: > Fix an issue detected by syzbot with KASAN: > > BUG: KASAN: vmalloc-out-of-bounds in cmd_to_func drivers/acpi/nfit/ > core.c:416 [inline] > BUG: KASAN: vmalloc-out-of-bounds in acpi_nfit_ctl+0x20e8/0x24a0 > drivers/acpi/nfit/core.c:459 > > The issue

Re: [PATCH] dax: Allow block size > PAGE_SIZE

2024-11-04 Thread Dave Chinner
VMM will satisfy by mmapping 128 16K pages from its page cache (at > arbitrary physical memory addresses) into guest "physical" memory as one > contiguous block. Then the guest will see the whole 2MiB mapping as > contiguous, even though it isn't in physical RAM, a

Re: [PATCH 08/13] media: i2c: imx214: Add vblank and hblank controls

2024-10-14 Thread Dave Stevenson
Hi André On Sat, 12 Oct 2024 at 22:46, André Apitzsch wrote: > > Hi Dave, > > Am Montag, dem 07.10.2024 um 18:29 +0100 schrieb Dave Stevenson: > > Hi Andre > > > > On Sun, 6 Oct 2024 at 22:41, André wrote: > > > > > > Hi Dave, > > > >

Re: [PATCH 08/13] media: i2c: imx214: Add vblank and hblank controls

2024-10-07 Thread Dave Stevenson
Hi Andre On Sun, 6 Oct 2024 at 22:41, André wrote: > > Hi Dave, > > Am Freitag, dem 13.09.2024 um 18:40 +0100 schrieb Dave Stevenson: > > On Thu, 12 Sept 2024 at 15:51, Dave Stevenson > > wrote: > > > > > > Hi André & Ricardo > > > >

Re: [PATCH v1] nvdimm: Correct some typos in comments

2024-09-26 Thread Dave Jiang
amepace ==> namespace > drivers/nvdimm/pmem.c:319: reenable ==> re-enable > > Signed-off-by: Shen Lichuan Reviewed-by: Dave Jiang > --- > drivers/nvdimm/nd_virtio.c | 2 +- > drivers/nvdimm/pfn_devs.c | 2 +- > drivers/nvdimm/pmem.c | 2 +- > 3 files changed, 3 inse

Re: [PATCH 08/13] media: i2c: imx214: Add vblank and hblank controls

2024-09-13 Thread Dave Stevenson
On Thu, 12 Sept 2024 at 15:51, Dave Stevenson wrote: > > Hi André & Ricardo > > On Thu, 12 Sept 2024 at 14:41, Ricardo Ribalda Delgado > wrote: > > > > Hi > > > > Arent you missing some chage in enum_frame_interval? > > Raw sensors shouldn't

Re: [PATCH 10/13] media: i2c: imx214: Implement vflip/hflip controls

2024-09-12 Thread Dave Stevenson
_LAYOUT; > + > + imx214->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, > + V4L2_CID_VFLIP, 0, 1, 1, 0); > + if (imx214->vflip) > + imx214->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LA

Re: [PATCH 08/13] media: i2c: imx214: Add vblank and hblank controls

2024-09-12 Thread Dave Stevenson
return ret; > > > > @@ -739,22 +805,26 @@ static int imx214_ctrls_init(struct imx214 *imx214) > > if (imx214->link_freq) > > imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; > > > > - /* > > -* WARNING! >

Re: [PATCH v2 2/2] x86/sgx: Log information when a node lacks an EPC section

2024-09-05 Thread Dave Hansen
On 9/5/24 07:24, Jarkko Sakkinen wrote: >> +for_each_online_node(nid) { >> +if (!node_isset(nid, sgx_numa_mask) && >> +node_state(nid, N_MEMORY) && node_state(nid, N_CPU)) >> +pr_info("node%d has both CPUs and memory but doesn't >> have an EPC se

Re: [PATCH] x86/sgx: Fix deadloop in __sgx_alloc_epc_page()

2024-08-30 Thread Dave Hansen
On 8/29/24 23:02, Aaron Lu wrote: >> Also, I do think we should probably add some kind of sanity warning to >> the SGX code in another patch. If a node on an SGX system has CPUs and >> memory, it's very likely it will also have some EPC. It can be >> something soft like a pr_info(), but I think i

Re: [PATCH] x86/sgx: Fix deadloop in __sgx_alloc_epc_page()

2024-08-29 Thread Dave Hansen
n *a* node that has SGX memory. This avoids the deadlock looking for the current SGX- lacking node to show up in the loop when it never will. The code looks fine, so feel free to add: Acked-by: Dave Hansen Also, I do think we should probably add some kind of sanity warning to

Re: [PATCH v2] virtio_pmem: Check device status before requesting flush

2024-08-20 Thread Dave Jiang
On 8/20/24 10:22 AM, Philip Chen wrote: > If a pmem device is in a bad status, the driver side could wait for > host ack forever in virtio_pmem_flush(), causing the system to hang. > > So add a status check in the beginning of virtio_pmem_flush() to return > early if the device is not activated

Re: [PATCH] nvdimm/pmem: Set dax flag for all 'PFN_MAP' cases

2024-08-07 Thread Dave Jiang
e the dax flag to queue_limits") > Signed-off-by: Zhihao Cheng Reviewed-by: Dave Jiang > --- > drivers/nvdimm/pmem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c > index 1ae8b2351654..210fb77f5

Re: [PATCH] nvdimm: Use of_property_present() and of_property_read_bool()

2024-08-07 Thread Dave Jiang
ar functions. > of_(find|get)_property() leak the DT struct property and data pointers > which is a problem for dynamically allocated nodes which may be freed. > > Signed-off-by: Rob Herring (Arm) Reviewed-by: Dave Jiang > --- > drivers/nvdimm/of_pmem.c | 2 +- > drivers/n

Re: [PATCH 0/2] Support userspace hypercalls for TDX

2024-07-03 Thread Dave Hansen
On 7/3/24 16:35, Tim Merrifield wrote: > VMCALL and VMMCALL instructions are used by x86 guests to request services > from the host VMM. Both VMCALL and VMMCALL are not restricted to CPL 0. > This allows userspace software like open-vm-tools to communicate directly > with the VMM. Could we please

Re: [PATCH v3 2/2] x86/sgx: Resolve EREMOVE page vs EAUG page data race

2024-06-07 Thread Dave Hansen
On 6/3/24 11:42, Haitao Huang wrote: >> Second, convince me that this _needs_ a new bit.  Why can't we just have >> a bit that effectively means "return EBUSY if you see this bit when >> handling a fault". > > IIUC, reclaimer_writing_to_pcmd() also uses > SGX_ENCL_PAGE_BEING_RECLAIMED to check if

Re: [PATCH] nvdimm: Fix devs leaks in scan_labels()

2024-06-06 Thread Dave Jiang
On 6/3/24 8:16 PM, Li Zhijian wrote: > Don't allocate devs again when it's valid pointer which has pionted to > the memory allocated above with size (count + 2 * sizeof(dev)). > > A kmemleak reports: > unreferenced object 0x88800dda1980 (size 16): > comm "kworker/u10:5", pid 69, jiffies 4

Re: [PATCH RESEND] nvdimm: add missing MODULE_DESCRIPTION() macros

2024-06-06 Thread Dave Jiang
ON() in drivers/nvdimm/nd_btt.o > WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvdimm/nd_e820.o > WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvdimm/of_pmem.o > WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvdimm/nd_virtio.o > > Signed-off-by:

Re: [PATCH] ACPI: NFIT: add missing MODULE_DESCRIPTION() macro

2024-06-06 Thread Dave Jiang
On 6/3/24 6:30 AM, Jeff Johnson wrote: > make allmodconfig && make W=1 C=1 reports: > WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/acpi/nfit/nfit.o > > Add the missing invocation of the MODULE_DESCRIPTION() macro. > > Signed-off-by: Jeff Johnson

Re: [PATCH v3 2/2] x86/sgx: Resolve EREMOVE page vs EAUG page data race

2024-05-28 Thread Dave Hansen
On 5/17/24 04:06, Dmitrii Kuvaiskii wrote: ... First, why is SGX so special here? How is the SGX problem different than what the core mm code does? > --- a/arch/x86/kernel/cpu/sgx/encl.h > +++ b/arch/x86/kernel/cpu/sgx/encl.h > @@ -25,6 +25,9 @@ > /* 'desc' bit marking that the page is being re

Re: [PATCH v3 0/2] x86/sgx: Fix two data races in EAUG/EREMOVE flows

2024-05-28 Thread Dave Hansen
On 5/17/24 04:06, Dmitrii Kuvaiskii wrote: > We wrote a trivial stress test to reproduce the hangs observed in > real-world applications. The test stresses #PF-based page allocation and > SGX_IOC_ENCLAVE_REMOVE_PAGES flows in the SGX driver: This seems like something we'd want in the kernel SGX se

Re: [RFC PATCH 00/20] Introduce the famfs shared-memory file system

2024-05-25 Thread Dave Chinner
x27;t work either. No device created in /dev (dax or pmem). I think you need to do some ndctl magic to get the memory to be namespaced correctly for the correct devices to appear. https://docs.pmem.io/ndctl-user-guide/managing-namespaces IIRC, need to set the type to pmem and the mode to fsdax, devdax or raw to get the relevant device nodes to be created for the range.. Cheers, Dave. -- Dave Chinner da...@fromorbit.com

Re: [PATCH] x86/paravirt: Disable virt spinlock when CONFIG_PARAVIRT_SPINLOCKS disabled

2024-05-23 Thread Dave Hansen
On 5/23/24 11:39, Jürgen Groß wrote: >> >> Let's just keep it simple.  How about the attached patch? > > Simple indeed. The attachment is empty. 😛 Let's try this again.diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 5358d43886ad..c193c9e60a1b 100644 --- a/arch/x86/kerne

Re: [PATCH] x86/paravirt: Disable virt spinlock when CONFIG_PARAVIRT_SPINLOCKS disabled

2024-05-23 Thread Dave Hansen
On 5/16/24 06:02, Chen Yu wrote: > Performance drop is reported when running encode/decode workload and > BenchSEE cache sub-workload. > Bisect points to commit ce0a1b608bfc ("x86/paravirt: Silence unused > native_pv_lock_init() function warning"). When CONFIG_PARAVIRT_SPINLOCKS > is disabled the v

Re: [PATCH v2 1/2] x86/sgx: Resolve EAUG race where losing thread returns SIGBUS

2024-05-15 Thread Dave Hansen
On 5/15/24 06:54, Jarkko Sakkinen wrote: > I'd cut out 90% of the description out and just make the argument of > the wrong error code, and done. The sequence is great for showing > how this could happen. The prose makes my head hurt tbh. The changelog is too long, but not fatally so. I'd much ra

Re: [PATCH 1/1] x86/vector: Fix vector leak during CPU offline

2024-05-10 Thread Dave Hansen
On 5/10/24 12:06, Dongli Zhang wrote: > } else { > + /* > + * This call borrows from the comments and implementation > + * of apic_update_vector(): "If the target CPU is offline > + * then the regular release mechanism via the cleanup > +

Re: [RFC PATCH v2 1/1] x86/sgx: Explicitly give up the CPU in EDMM's ioctl() to avoid softlockup

2024-04-26 Thread Dave Hansen
On 4/26/24 07:18, Bojun Zhu wrote: > for (c = 0 ; c < modp->length; c += PAGE_SIZE) { > + if (sgx_check_signal_and_resched()) { > + if (!c) > + ret = -ERESTARTSYS; > + > + goto out; > + } This constru

Re: [PATCH v12 14/14] selftests/sgx: Add scripts for EPC cgroup testing

2024-04-26 Thread Dave Hansen
On 4/16/24 07:15, Jarkko Sakkinen wrote: > On Tue Apr 16, 2024 at 8:42 AM EEST, Huang, Kai wrote: > Yes, exactly. I'd take one week break and cycle the kselftest part > internally a bit as I said my previous response. I'm sure that there > is experise inside Intel how to implement it properly. I.e.

Re: [PATCH][next] dax: remove redundant assignment to variable rc

2024-04-15 Thread Dave Jiang
ning: Value stored to 'rc' is never > read [deadcode.DeadStores] > > Signed-off-by: Colin Ian King Reviewed-by: Dave Jiang > --- > drivers/dax/bus.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > index 797e

Re: [PATCH v9 15/15] selftests/sgx: Add scripts for EPC cgroup testing

2024-04-02 Thread Dave Hansen
On 3/30/24 04:23, Jarkko Sakkinen wrote: >>> I also wonder is cgroup-tools dependency absolutely required or could >>> you just have a function that would interact with sysfs? >> I should have checked email before hit the send button for v10 🙂. >> >> It'd be more complicated and less readable to do

[GIT PULL] NVDIMM//DAX changes for 6.9

2024-03-14 Thread Dave Jiang
Hi Linus, please pull from: git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git tags/libnvdimm-for-6.9 ... to get updates to the nvdimm tree. They are a number of updates to interfaces used by nvdimm/dax and a documentation fix. Doc fixes: ACPI_NFIT Kconfig documetation f

Re: [PATCH] dax: remove SLAB_MEM_SPREAD flag usage

2024-02-27 Thread Dave Jiang
On 2/24/24 6:47 AM, chengming.z...@linux.dev wrote: > From: Chengming Zhou > > The SLAB_MEM_SPREAD flag is already a no-op as of 6.8-rc1, remove > its usage so we can delete it from slab. No functional change. Can you please provide a Link tag to the lore post that indicates SLAB_MEM_SPREAD

Re: [PATCH v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge()

2024-02-26 Thread Dave Hansen
On 2/26/24 14:34, Huang, Kai wrote: > So I am trying to get the actual downside of doing per-cgroup reclaim or > the full reason that we choose global reclaim. Take the most extreme example: while (hit_global_sgx_limit()) reclaim_from_this(cgroup); You eventually end up w

Re: [PATCH v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge()

2024-02-26 Thread Dave Hansen
On 2/26/24 14:24, Huang, Kai wrote: > What is the downside of doing per-group reclaim when try_charge() > succeeds for the enclave but failed to allocate EPC page? > > Could you give an complete answer why you choose to use global reclaim > for the above case? There are literally two different li

Re: [PATCH v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge()

2024-02-26 Thread Dave Hansen
On 2/26/24 13:48, Haitao Huang wrote: > In case of overcomitting, i.e., sum of limits greater than the EPC > capacity, if one group has a fault, and its usage is not above its own > limit (try_charge() passes), yet total usage of the system has exceeded > the capacity, whether we do global reclaim

Re: [PATCH v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge()

2024-02-26 Thread Dave Hansen
On 2/26/24 03:36, Huang, Kai wrote: >> In case of overcomitting, even if we always reclaim from the same cgroup >> for each fault, one group may still interfere the other: e.g., consider an >> extreme case in that group A used up almost all EPC at the time group B >> has a fault, B has to fai

Re: [PATCH] dax: constify the struct device_type usage

2024-02-23 Thread Dave Jiang
read-only memory which can not be modified at runtime. > > Cc: Greg Kroah-Hartman > Signed-off-by: Ricardo B. Marliere Reviewed-by: Dave Jiang > --- > drivers/dax/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dax/bus.c b/driver

Re: [RFC PATCH] x86/sgx: Remove 'reclaim' boolean parameters

2024-02-19 Thread Dave Hansen
On 2/19/24 07:39, Haitao Huang wrote: > Remove all boolean parameters for 'reclaim' from the function > sgx_alloc_epc_page() and its callers by making two versions of each > function. > > Also opportunistically remove non-static declaration of > __sgx_alloc_epc_page() and a typo > > Signed-off-by

Re: [PATCH v9 09/15] x86/sgx: Charge mem_cgroup for per-cgroup reclamation

2024-02-16 Thread Dave Hansen
On 2/16/24 13:38, Haitao Huang wrote: > On Fri, 16 Feb 2024 09:15:59 -0600, Dave Hansen > wrote: ... >> Does this 'indirect' change any behavior other than whether it does a >> search for an mm to find a place to charge the backing storage? > > No. > >>

Re: [PATCH v9 09/15] x86/sgx: Charge mem_cgroup for per-cgroup reclamation

2024-02-16 Thread Dave Hansen
On 2/5/24 13:06, Haitao Huang wrote: > @@ -414,7 +416,7 @@ static void sgx_reclaim_pages_global(void) > void sgx_reclaim_direct(void) > { > if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) > - sgx_reclaim_pages_global(); > + sgx_reclaim_pages_global(false); > } > > stat

Re: [PATCH v9 09/15] x86/sgx: Charge mem_cgroup for per-cgroup reclamation

2024-02-15 Thread Dave Hansen
On 2/5/24 13:06, Haitao Huang wrote: > static struct mem_cgroup *sgx_encl_get_mem_cgroup(struct sgx_encl *encl) > { > @@ -1003,14 +1001,6 @@ static struct mem_cgroup > *sgx_encl_get_mem_cgroup(struct sgx_encl *encl) > struct sgx_encl_mm *encl_mm; > int idx; > > - /* > - *

Re: [PATCH] device-dax: make dax_bus_type const

2024-02-05 Thread Dave Jiang
g Kroah-Hartman > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Ricardo B. Marliere Reviewed-by: Dave Jiang > --- > drivers/dax/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > index 1659b787b65f..

Re: [PATCH] nvdimm: make nvdimm_bus_type const

2024-02-05 Thread Dave Jiang
g Kroah-Hartman > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Ricardo B. Marliere Reviewed-by: Dave Jiang > --- > drivers/nvdimm/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c > index ef

Re: [RFC PATCH v2 7/8] Introduce dcache_is_aliasing() across all architectures

2024-01-31 Thread Dave Chinner
On Wed, Jan 31, 2024 at 09:58:21AM -0500, Mathieu Desnoyers wrote: > On 2024-01-30 21:48, Dave Chinner wrote: > > On Tue, Jan 30, 2024 at 11:52:54AM -0500, Mathieu Desnoyers wrote: > > > Introduce a generic way to query whether the dcache is virtually aliased > > >

Re: [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures

2024-01-30 Thread Dave Chinner
ot;) > Signed-off-by: Mathieu Desnoyers > Cc: Andrew Morton > Cc: Linus Torvalds > Cc: linux...@kvack.org > Cc: linux-a...@vger.kernel.org > Cc: Dan Williams > Cc: Vishal Verma > Cc: Dave Jiang > Cc: Matthew Wilcox > Cc: Arnd Bergmann > Cc: Russell King &

Re: [RFC PATCH v2 7/8] Introduce dcache_is_aliasing() across all architectures

2024-01-30 Thread Dave Chinner
igurations with the VFS dentry cache aliasing when we read this code? Something like cpu_dcache_is_aliased(), perhaps? -Dave. -- Dave Chinner da...@fromorbit.com

Re: [RFC PATCH v2 1/8] dax: Introduce dax_is_supported()

2024-01-30 Thread Dave Chinner
detect > dcache aliasing at runtime. > > Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing > caches") > Signed-off-by: Mathieu Desnoyers > Cc: Andrew Morton > Cc: Linus Torvalds > Cc: linux...@kvack.org > Cc: linux-a...@vger.kernel.org >

Re: [RFC PATCH 7/7] xfs: Use dax_is_supported()

2024-01-29 Thread Dave Chinner
an Babu R > Cc: Darrick J. Wong > Cc: linux-...@vger.kernel.org > Cc: Andrew Morton > Cc: Linus Torvalds > Cc: linux...@kvack.org > Cc: linux-a...@vger.kernel.org > Cc: Dan Williams > Cc: Vishal Verma > Cc: Dave Jiang > Cc: Matthew Wilcox > Cc: nvd...@li

Re: [PATCH v6 00/12] Add Cgroup support for SGX EPC memory

2024-01-05 Thread Dave Hansen
There's very little about how the LRU design came to be in this cover letter. Let's add some details. How's this? Writing this up, I'm a lot more convinced that this series is, in general, taking the right approach. I honestly don't see any other alternatives. As much as I'd love to do somethi

Re: [PATCH v6 07/12] x86/sgx: Introduce EPC page states

2024-01-05 Thread Dave Hansen
On 10/30/23 11:20, Haitao Huang wrote: > @@ -527,16 +530,13 @@ void sgx_mark_page_reclaimable(struct sgx_epc_page > *page) > int sgx_unmark_page_reclaimable(struct sgx_epc_page *page) > { > spin_lock(&sgx_global_lru.lock); > - if (page->flags & SGX_EPC_PAGE_RECLAIMER_TRACKED) { > -

Re: [PATCH v6 09/12] x86/sgx: Restructure top-level EPC reclaim function

2024-01-04 Thread Dave Hansen
On 1/4/24 11:11, Haitao Huang wrote: > If those are OK with users and also make it acceptable for merge > quickly, I'm happy to do that 🙂 How about we put some actual numbers behind this? How much complexity are we talking about here? What's the diffstat for the utterly bare-bones implementation

Re: [PATCH v6 09/12] x86/sgx: Restructure top-level EPC reclaim function

2024-01-03 Thread Dave Hansen
On 12/18/23 13:24, Haitao Huang wrote:> @Dave and @Michal, Your thoughts? Or could you confirm we should not > do reclaim per cgroup at all? What's the benefit of doing reclaim per cgroup? Is that worth the extra complexity? The key question here is whether we want the SGX VM to be

Re: [PATCH] driver core: Add a guard() definition for the device_lock()

2023-12-14 Thread Dave Jiang
Cc: Ira Weiny > Cc: Peter Zijlstra > Cc: Greg Kroah-Hartman > Cc: Andrew Morton > Signed-off-by: Dan Williams Reviewed-by: Dave Jiang > --- > Hi Greg, > > I wonder if you might include this change in v6.7-rc to ease some patch > sets alternately going through my tree and

Re: [PATCH] [v2] nvdimm-btt: simplify code with the scope based resource management

2023-12-14 Thread Dave Jiang
On 12/14/23 01:39, Dinghao Liu wrote: > Use the scope based resource management (defined in > linux/cleanup.h) to automate resource lifetime > control on struct btt_sb *super in discover_arenas(). > > Signed-off-by: Dinghao Liu Reviewed-by: Dave Jiang > --- > > Cha

Re: [PATCH] nvdimm-btt: simplify code with the scope based resource management

2023-12-13 Thread Dave Jiang
On 12/12/23 20:12, dinghao@zju.edu.cn wrote: >> >> On 12/10/23 03:27, Dinghao Liu wrote: >>> Use the scope based resource management (defined in >>> linux/cleanup.h) to automate resource lifetime >>> control on struct btt_sb *super in discover_arenas(). >>> >>> Signed-off-by: Dinghao Liu >>

Re: [PATCH] nvdimm: Remove usage of the deprecated ida_simple_xx() API

2023-12-11 Thread Dave Jiang
On 12/10/23 10:13, Christophe JAILLET wrote: > ida_alloc() and ida_free() should be preferred to the deprecated > ida_simple_get() and ida_simple_remove(). > > This is less verbose. > > Signed-off-by: Christophe JAILLET Reviewed-by: Dave Jiang > --- > drivers/nvd

Re: [PATCH] nvdimm-btt: simplify code with the scope based resource management

2023-12-11 Thread Dave Jiang
On 12/10/23 03:27, Dinghao Liu wrote: > Use the scope based resource management (defined in > linux/cleanup.h) to automate resource lifetime > control on struct btt_sb *super in discover_arenas(). > > Signed-off-by: Dinghao Liu > --- > drivers/nvdimm/btt.c | 12 > 1 file changed,

Re: [PATCH] nvdimm-btt: fix a potential memleak in btt_freelist_init

2023-12-07 Thread Dave Jiang
On 12/6/23 20:43, Dinghao Liu wrote: > When an error happens in btt_freelist_init(), its caller > discover_arenas() will directly free arena, which makes > arena->freelist allocated in btt_freelist_init() a leaked > memory. Fix this by freeing arena->freelist in all error > handling paths of btt

Re: [PATCH v7 00/13] selftests/sgx: Fix compilation errors

2023-11-08 Thread Dave Hansen
On 11/8/23 12:31, Jo Van Bulck wrote: > Just a kind follow-up: from what I can see, this series has not been > merged into the x86/sgx branch of tip yet (assuming that's where it > should go next)? > > Apologies if I've overlooked anything, and please let me know if there's > something on my end t

Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-10-18 Thread Dave Hansen
On 10/18/23 08:26, Haitao Huang wrote: > Maybe not in sense of killing something. My understanding memory.reclaim > does not necessarily invoke the OOM killer. But what I really intend to > say is we can have a separate knob for user to express the need for > reducing the current usage explicitly a

Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-10-18 Thread Dave Hansen
On 10/17/23 21:37, Haitao Huang wrote: > Yes we can introduce misc.reclaim to give user a knob to forcefully > reducing usage if that is really needed in real usage. The semantics > would make force-kill VMs explicit to user. Do any other controllers do something like this? It seems odd.

[GIT PULL] NVDIMM Fixes for 6.6-rc5

2023-10-02 Thread Dave Jiang
Hi Linus, please pull from: git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git tags/libnvdimm-fixes-6.6-rc5 ...to receive a small fix for libnvdimm correcting the calculation of idt size in the NFIT code. It has appeared in -next for a few days with no reported issues. --- The f

Re: [PATCH v1 1/1] ACPI: NFIT: Switch to use acpi_evaluate_dsm_typed()

2023-10-02 Thread Dave Jiang
On 10/2/23 06:54, Andy Shevchenko wrote: > The acpi_evaluate_dsm_typed() provides a way to check the type of the > object evaluated by _DSM call. Use it instead of open coded variant. > > Signed-off-by: Andy Shevchenko Reviewed-by: Dave Jiang > --- > drivers/acpi/nfit/cor

Re: [PATCH v6] x86/sgx: Resolves SECS reclaim vs. page fault for EAUG race

2023-09-28 Thread Dave Hansen
On 9/28/23 16:08, Reinette Chatre wrote: > I'd like to check in on the status of this patch. This two month old > patch looks to be a needed fix and has Jarkko and Kai's review tags, > but I am not able to find it queued or merged in tip or upstream. > Apologies if I did not look in the right spot,

Re: [PATCH v1 1/2] ACPI: NFIT: Fix memory leak, and local use of devm_*()

2023-09-26 Thread Dave Jiang
ak'. > > Fix this by switching from devm_kcalloc() to kcalloc(), and adding > proper rollback. > > Fixes: eaf961536e16 ("libnvdimm, nfit: add interleave-set state-tracking > infrastructure") > Reported-by: Andy Shevchenko > Signed-off-by: Michal W

Re: [PATCH v1 2/2] ACPI: NFIT: Use modern scope based rollback

2023-09-26 Thread Dave Jiang
On 9/26/23 11:45, Michal Wilczynski wrote: > Change rollback in acpi_nfit_init_interleave_set() to use modern scope > based attribute __free(). This is similar to C++ RAII and is a preferred > way for handling local memory allocations. > > Suggested-by: Dave Jiang >

Re: [PATCH v4 03/18] x86/sgx: Add sgx_epc_lru_lists to encapsulate LRU lists

2023-09-14 Thread Dave Hansen
On 9/14/23 03:31, Huang, Kai wrote: >> Signed-off-by: Haitao Huang >> Cc: Sean Christopherson > You don't need 'Cc:' Sean if the patch has Sean's SoB. It is a SoB for Sean's @intel address and cc's his @google address. It is fine.

Re: [PATCH v3] libnvdimm/of_pmem: Use devm_kstrdup instead of kstrdup and check its return value

2023-09-14 Thread Dave Jiang
On 9/14/23 00:03, Chen Ni wrote: > Use devm_kstrdup() instead of kstrdup() and check its return value to > avoid memory leak. > > Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus > provider") > Signed-off-by: Chen Ni Reviewed-by: Dave J

Re: [PATCH] dax: refactor deprecated strncpy

2023-09-13 Thread Dave Jiang
Cc: linux-harden...@vger.kernel.org > Signed-off-by: Justin Stitt Reviewed-by: Dave Jiang > --- > Note: build-tested only. > --- > drivers/dax/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > index 0ee9

Re: [PATCH] x86/tdx: refactor deprecated strncpy

2023-09-11 Thread Dave Hansen
On 9/11/23 11:27, Justin Stitt wrote: > `strncpy` is deprecated and we should prefer more robust string apis. I dunno. It actually seems like a pretty good fit here. > In this case, `message.str` is not expected to be NUL-terminated as it > is simply a buffer of characters residing in a union wh

Re: [PATCH] drivers: nvdimm: fix possible memory leak

2023-09-08 Thread Dave Jiang
On 9/5/23 02:15, Konstantin Meskhidze wrote: Memory pointed by 'nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs[0]' is allocated in function 'nvdimm_pmu_cpu_hotplug_init' via 'create_cpumask_attr_group' call. But not released in function 'nvdimm_pmu_free_hotplug_memory' or anywhere els

[GIT PULL] NVDIMM and DAX for 6.6

2023-08-30 Thread Dave Jiang
Hi Linus, please pull from git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git tags/libnvdimm-for-6.6 ... to receive the libnvdimm and DAX updates for v6.6 This is mostly small cleanups, fixes, and with a change to prevent zero-sized namespace exposed to user for nvdimm. It ha

Re: [PATCH] nvdimm: of_pmem: Add kfree for kstrdup

2023-08-28 Thread Dave Jiang
On 8/27/23 23:23, Chen Ni wrote: Add kfree() for kstrdup() in order to avoid memory leak. Signed-off-by: Chen Ni Can you please add a fixes tag? Thanks! --- drivers/nvdimm/of_pmem.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_

Re: [PATCH] drivers: nvdimm: fix dereference after free

2023-08-17 Thread Dave Jiang
On 8/17/23 08:45, Dave Jiang wrote: On 8/17/23 04:41, Konstantin Meskhidze wrote: 'nd_pmu->pmu.attr_groups' is dereferenced in function 'nvdimm_pmu_free_hotplug_memory' call after it has been freed. Because in function 'nvdimm_pmu_free_hotplug_memory'

Re: [PATCH] drivers: nvdimm: fix memleak

2023-08-17 Thread Dave Jiang
On 8/17/23 04:59, Konstantin Meskhidze wrote: Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function 'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function 'unregister_nvdimm_pmu'. Co-developed-by: Ivanov Mikhail Signed-off-by: Konstantin Meskhidze Applied

Re: [PATCH] drivers: nvdimm: fix dereference after free

2023-08-17 Thread Dave Jiang
On 8/17/23 04:41, Konstantin Meskhidze wrote: 'nd_pmu->pmu.attr_groups' is dereferenced in function 'nvdimm_pmu_free_hotplug_memory' call after it has been freed. Because in function 'nvdimm_pmu_free_hotplug_memory' memory pointed by the fields of 'nd_pmu->pmu.attr_groups' is deallocated it is

Re: [PATCH v2] ACPI: NFIT: limit string attribute write

2023-07-11 Thread Dave Jiang
On 7/11/23 02:37, Ben Dooks wrote: If we're writing what could be an arbitrary sized string into an attribute we should probably use sysfs_emit() just to be safe. Most of the other attriubtes are some sort of integer so unlikely to be an issue so not altered at this time. Signed-off-by: Ben D

Re: [PATCH] ACPI: NFIT: add helper to_nfit_mem() to take device to nfit_mem

2023-07-05 Thread Dave Jiang
Dooks Reviewed-by: Dave Jiang --- drivers/acpi/nfit/core.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 0fcc247fdfac..9213b426b125 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers

  1   2   3   4   5   6   7   8   9   10   >