Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp248107lqb; Thu, 14 Mar 2024 10:08:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXO4bVBVgjIpVfwb4ct6JHFEKjw7OUaxBt6CfR2hEdH3HmPRjnREhVoWRqHBs2xmpGnzUdndk1jGgeokzkQ/XHFsNwY3yaZ9ydMDFWo2w== X-Google-Smtp-Source: AGHT+IHkTvh4JMx6UH1oGRdh22PiO/g5nFqHC6Q9ULPy6Iym1O2la5vi+nhwup5YxuHN7oLwOvNO X-Received: by 2002:ac8:7fc4:0:b0:430:ad44:9d6b with SMTP id b4-20020ac87fc4000000b00430ad449d6bmr60783qtk.25.1710436117215; Thu, 14 Mar 2024 10:08:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710436117; cv=pass; d=google.com; s=arc-20160816; b=BRvtMfQU+ESJRFF0Xm6VSDvKn2zW9UYhRQ3vC0FU/zj33xAnprf3oksYTLSJ/Pan7u K6JrBOh+tP8XlqWR1yVacdmC+aePcQ8bzl9NrnZjIfn+j7Td5g86pPbPtP/jNzKCeyqt zmVUTCGl6Sj04nQ/QUYGvgtM03rpJJCk+fyPxl0RUvxtAxK+ZL4trfHbN/i+Nsy7lxVE s24tc7Wwka98LgJAJ6C7Sx+cfT9tLnQ0d6XlRAdVzHkdGVcfjnm1H41zYUNtNBm/rAUC 2QacxVz0nf+s+Vgl5XEcPcfjBDuWUU8WPODS7ZHi+hCc5lsUMaY9RMScxcnBXRlI/8YV K8FA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=IRts4rkBVcGeXEcRt2MTupfVX97nL0afashtKjZXc+M=; fh=vsxtrCdS0S4A7INxeH5WwuwjDCY7p+3lMESQcxCLkVE=; b=hEOfaonLhn5W8cULuDLVACiKkoJ/8GbEEVfyIArsm2+c+qIX3oVnw/RjS6McgzJ4Xk HsoJGrH1UewH3YHPcW7s9dR5+yy9zvEQqGsvlvOaIqlyneh0HBnLS6qidHc0UBjlaH/5 SpZaIZBb6czAwEAH/7W3ZsqE+zSAidyaxPLFxHHijYl/xvj9TmXjASburvN2jj5lE4qa MhvybrGWBJ/2GB5+ONLIxgPgWejXx1Un43t5X6MsDwr5FG40UpykakcoDLTl50xU7EF9 CmYlpYua+32xMdgVKGURd2DWiJ7MIYFP5Z8KOi9xSZ0k7vY39oMDjqE+HbdHvx7o4Vuo ka6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eWbCqdJ+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-103605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p10-20020a05622a048a00b0042eb222447dsi1872558qtx.283.2024.03.14.10.08.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 10:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eWbCqdJ+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-103605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EB3AA1C20CCF for ; Thu, 14 Mar 2024 17:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B9EB7443F; Thu, 14 Mar 2024 17:08:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eWbCqdJ+" Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) (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 116236E610; Thu, 14 Mar 2024 17:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710436109; cv=none; b=Cty5AXw3jhE3u7s/IVcdLh0gL/myY2nP4wSGCHPTS00yjhDAFXkzYMECB9oXAUwnVaSCKwKqmoIGAxyPVTql8+8BSDSc0I65eWQtMhxkHvZCilrsx3bqUeHWysMY0PFuFEbdDJDSzkxG/HOldtb5WnUQltCjH4EywBtE1zYPz/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710436109; c=relaxed/simple; bh=fbB5AxAdKo0wy6VhS6ZRq9Tyrk+J/JRWJyQZyo4j0PM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YcIMcfXo2vt3kjxQM5X7FvzZk4TM5Dk5c7uOk/v+6CYBgbD7pfq1ioVdTehw1XT1JCeAjrIhEaqDYQwa3jnJvHGeZx0YfghcMw8qy6fPwjmwrLxbh9zM/okLI2fR3vX79RDDoCHfqimriSqI6I75Ar7pOpNwNwFRVkWMIwq92fA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eWbCqdJ+; arc=none smtp.client-ip=209.85.218.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f68.google.com with SMTP id a640c23a62f3a-a466a1f9ea0so153838266b.1; Thu, 14 Mar 2024 10:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710436106; x=1711040906; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IRts4rkBVcGeXEcRt2MTupfVX97nL0afashtKjZXc+M=; b=eWbCqdJ+B6S19Up1ODitWvyN/nMkT4YZXVBQXXUI+O+rIDc4I9QuhZxtWenPjawxC7 buIkHMpD8xTaVRb21ZcsGnMSl1waLRixq4YJbHvierpAHlR8KzKYpaZ1FC34qVU48DIh fTJII3bBIbl7yk4zQhCxsZqdtTzodDBphkWcvFNWKRhU8hh9uBL8EbaVQfx01qNX7i/t s5QWbQ6Hr9JrXc8HJV4PArpQhT7vQLTRFMJHREJIUks9BMfv3oiWjsp4pA9CWVOOOydq U7CMtaQcSf+G664QZkpeLS4g1DymymFaYL7z3PTnW7RRC0tcrEM/Av389WIbZ6vdDlgN ETkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710436106; x=1711040906; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IRts4rkBVcGeXEcRt2MTupfVX97nL0afashtKjZXc+M=; b=sWY+UhbM9Us2xWASdaM0JOmtIRWO4G02Zb065EVFYLjZN0ksBii9Yu+r20F7NoMNgU Tf3D4Y1B/ptmZ+g5fUTi4V0lECh2brcBy5c6dxcck+oG+FMdT/lt4KFrJNZQKO0aj2uG 02Ai4hSB71PKfalBc7vAO1HxY3Sbl7OvstDIu86kWqIQojv74kvMaZXy8GG/TUJzQebA ocVQgnjEvzijIYhMvsj1JrlgVbwxvbkcMA1A2x3UoaY07JuGSY8CORrwFfkS+diwNRjW +NzHb/DsjSyk+1PdtJrRQbGX7JJBzrYibjKveKn1c6v8C7cjFnRLtufa0AbqckzyWH6z xN2w== X-Forwarded-Encrypted: i=1; AJvYcCU96Etkq+6nzSA72QuH4WwFWoQjkB0CD761HGpOTS2G+54dmFRtGZMjc+cj58XG9u9KKCACg9tKLHere9e0keewqIq/5mOSzFDH+G80Q4H/RtIQmW5tjP8nygMsCZOeojb1 X-Gm-Message-State: AOJu0Ywhg2x5wamqQZVdfncMoL4wR4i5ciKD+6tUEDO79OugDtHE4HyU HRD8WX1ymwSa9Mi+AQtRA3zpHbYCbaSenv10lZLHOJudT0/UiAWtnWDBVeyr/6EtftlEilTM9q/ ZkQgq/N03iOyr5/g+cYofeTHAheY= X-Received: by 2002:aa7:c2c4:0:b0:567:2a22:6e86 with SMTP id m4-20020aa7c2c4000000b005672a226e86mr960099edp.22.1710436106036; Thu, 14 Mar 2024 10:08:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240314150003.123020-1-puranjay12@gmail.com> <20240314150003.123020-2-puranjay12@gmail.com> In-Reply-To: <20240314150003.123020-2-puranjay12@gmail.com> From: Kumar Kartikeya Dwivedi Date: Thu, 14 Mar 2024 18:07:49 +0100 Message-ID: Subject: Re: [PATCH bpf-next 1/2] bpf: Add arm64 JIT support for PROBE_MEM32 pseudo instructions. To: Puranjay Mohan , Alexei Starovoitov , Eduard Zingerman Cc: Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Zi Shen Lim , Xu Kuohai Content-Type: text/plain; charset="UTF-8" On Thu, 14 Mar 2024 at 16:00, Puranjay Mohan wrote: > > Add support for [LDX | STX | ST], PROBE_MEM32, [B | H | W | DW] > instructions. They are similar to PROBE_MEM instructions with the > following differences: > - PROBE_MEM32 supports store. > - PROBE_MEM32 relies on the verifier to clear upper 32-bit of the > src/dst register > - PROBE_MEM32 adds 64-bit kern_vm_start address (which is stored in R28 > in the prologue). Due to bpf_arena constructions such R28 + reg + > off16 access is guaranteed to be within arena virtual range, so no > address check at run-time. > - PROBE_MEM32 allows STX and ST. If they fault the store is a nop. When > LDX faults the destination register is zeroed. > > To support these on arm64, we do tmp2 = R28 + src/dst reg and then use > tmp2 as the new src/dst register. This allows us to reuse most of the > code for normal [LDX | STX | ST]. > > Signed-off-by: Puranjay Mohan > --- Hi Alexei, Puranjay and I were discussing this stuff off list and noticed that atomic instructions are not handled. It turns out that will cause a kernel crash right now because the 32-bit offset into arena will be dereferenced directly. e.g. something like this: @@ -55,6 +56,7 @@ int arena_list_add(void *ctx) test_val++; n->value = i; arena_sum += i; + __sync_fetch_and_add(&arena_sum, 0); list_add_head(&n->node, list_head); } #else I will try to prepare a fix for the x86 JIT. Puranjay will do the same for his set.