From patchwork Fri Feb 23 03:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 775125 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp155693wrb; Thu, 22 Feb 2024 19:03:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWlCbZrz6l3PR0+mjlwrGt40pDW4qL74ZfwXe/P+evqi/3SNENOp4snGsAK+eP9sSShWrmhKwav/cFFeZCpQjhY X-Google-Smtp-Source: AGHT+IFZbiSbBn8RrIpq8AYaM5HlzuH4e843ufle8idrIH3e1cYBqDX786ewanx3f/L/Oy5hjDYZ X-Received: by 2002:a05:6214:5c04:b0:68f:8a1f:ca25 with SMTP id ly4-20020a0562145c0400b0068f8a1fca25mr7625587qvb.12.1708657420744; Thu, 22 Feb 2024 19:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708657420; cv=none; d=google.com; s=arc-20160816; b=VuBi9cuXdEBPRSdsBQfXP/njJEjznNK2yQOqfY3+V0xCU+eOpoeElxOUTfOEf3UfK+ +8A6Ung+fq4ka3XXWb1K7u+JVRbfT7zATANlewomRlepQFIEDXluF7OrseKMkaL/2xWx oJz0PGRVfGfqp/m2Qn9udSHd6lrietERnrbEh8u0PWLDKqRYbRqmwM9GhdacGMBzUEi2 Pr1IlnniVA2XARzokSY6UmsuTB4uz10oYAB2ivIgS7M2+huD12+ArdSRZ4FqS8cvsKJ4 a3zmB0PBUnD9n61lGF4bWTMgKBuK0icpZuoLjY6vVQ3hpLp3amrnKxWUPFQTtaya44xr aorg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SHlUnJMkSLjXViHQWxp6vaRXYVXn1e/U/gKCQwR45lE=; fh=8KSwxPSjG7lTAUAQ/arcVl4mtuWJVDifA7pB1X1/PJk=; b=siEi/ySySAlhgTqugjg9CWFD4HXgUnwdcYlJsxDd7WtxWMNpWI/A4LJgxfbPvFPhMQ cPFfUI18Nw0s0EuR1w/7vGs+W5TQsZxiJsCNAGp5cDWCdplGPyZSmVHSxCtliwpTf/6U J1ZlRdG7KsDJNjW+M3xDyAOuufs2tkSK17F4yjgdkPqXAe4WXpZLOMcl3fa8nZ7rYRFL kj7aqRH6Z4udCVwqX1/saHFVui2tFAYQSGqFehAN8eLc2ijJmuWO0iNHWOhRAPn8cDYR k39Lda0szdlfhhleQmRGe+ophTznXogF/Fm8urfRfLMyfwB4LxIHvfRHunGbrlT6xzTI V2Yg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OHAp4duw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u37-20020a05622a19a500b0042e5fe99218si688395qtc.508.2024.02.22.19.03.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2024 19:03:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OHAp4duw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdLqJ-0002br-IL; Thu, 22 Feb 2024 22:03:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdLqH-0002bH-Bn for qemu-devel@nongnu.org; Thu, 22 Feb 2024 22:03:17 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdLqF-0000cR-Uq for qemu-devel@nongnu.org; Thu, 22 Feb 2024 22:03:17 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e08dd0fa0bso411318b3a.1 for ; Thu, 22 Feb 2024 19:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708657394; x=1709262194; darn=nongnu.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=SHlUnJMkSLjXViHQWxp6vaRXYVXn1e/U/gKCQwR45lE=; b=OHAp4duwjt6L6OBs2GKA5uIiRgF3QH5pO1HCXniUppqUjyzkAvLaVZxKglY2JTdiqc O+5UimwD4LCxVBE6hZuP09UitQ8NhNi7NVexlmW8o2kyQPKbqmK8RkBeIQxzhpRBhq0p gNoPGXjebjC0w6Zf6sokT8DgbdpFwylN8vTATgC6v3vBJPXo0uqp2Ic3QEracHY/cSSQ NYE1POZjdp3Idkf2EKw84lb0hOhCpAweQN8UugIXnQgZcT3Mp/IhkebaYVmcmP5SaMST 0SXceMqZinkxXetx2E9Jd0RF6Jq5AvzWPptCaxoCiBSxJ5o8VLKFdqfLSt9FoqjjZr2J EKMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708657394; x=1709262194; 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=SHlUnJMkSLjXViHQWxp6vaRXYVXn1e/U/gKCQwR45lE=; b=YaZ0USds2u9PV4aAWj+8zblI5CKNBKmbTaNCesD3sjHjZ6wcIuH5UtB87BwYNsNQU/ SO2D9y5qYoQtHgdpdPRc+arjdSZqUXeleQvp7KhW027h3CgwQfhodS6ZfTpC9895P0DP KcgR2rTJNOCvUSdPJuj8bnENTH9LyJ9Pthhj3hey4gGqP+Ay2yWWKvcE0YbW/TxLQntb w6qWhluXvMdnAz06xLPYtIe9DpxIg+pTjqJxHfALdEBaCS8kDjtN2SCAe3GRNBkv3OvL Ygz1fXFZhsu1zQdRl+ahocllo3sYRWLcTD1ttlc6y9slabOIpSM+UpgTe/EcwcSN0VzT hdwg== X-Gm-Message-State: AOJu0Yy+VN1+kCgWoTAZ/2JKu/q3HSLL6diQd0CA4peF1SV71yqoUNFd 2H7qLHSThOF+3KmYqMHZdU94yTJpjOp/+kNQWHgcjYBV7G69AjCinH+wPu2pJB0eHZDal7rYhZe k X-Received: by 2002:a05:6a00:9a3:b0:6e4:74d9:6f0f with SMTP id u35-20020a056a0009a300b006e474d96f0fmr1449327pfg.0.1708657394267; Thu, 22 Feb 2024 19:03:14 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id n38-20020a056a000d6600b006e31f615af6sm11594159pfv.17.2024.02.22.19.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 19:03:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, iii@linux.ibm.com, richard.purdie@linuxfoundation.org, mjt@tls.msk.ru, Song Gao Subject: [PATCH 1/3] linux-user/loongarch64: Remove TARGET_FORCE_SHMLBA Date: Thu, 22 Feb 2024 17:03:07 -1000 Message-Id: <20240223030309.458451-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223030309.458451-1-richard.henderson@linaro.org> References: <20240223030309.458451-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The upstream linux kernel does not define __ARCH_FORCE_SHMLBA. Cc: Song Gao Signed-off-by: Richard Henderson Reviewed-by: Song Gao --- Did this definition come from the port before it was merged upstream? Or was it incorrectly copied from MIPS? --- linux-user/loongarch64/target_syscall.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/linux-user/loongarch64/target_syscall.h b/linux-user/loongarch64/target_syscall.h index 8b5de52124..39f229bb9c 100644 --- a/linux-user/loongarch64/target_syscall.h +++ b/linux-user/loongarch64/target_syscall.h @@ -38,11 +38,4 @@ struct target_pt_regs { #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 -#define TARGET_FORCE_SHMLBA - -static inline abi_ulong target_shmlba(CPULoongArchState *env) -{ - return 64 * KiB; -} - #endif From patchwork Fri Feb 23 03:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 775126 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp155760wrb; Thu, 22 Feb 2024 19:03:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXguklXzEtQQlr6k3xe6BNpfWBYQ6X4Z4+e1m+VOsxtOIBWONvauIta1WDPGp+Ck6Gy6iV1yYaajLU/qC/Htf3P X-Google-Smtp-Source: AGHT+IEq7+9x4lrZY2xYv05vvzt8meSkK1V+ncXas9RhBA9UJMH0lEPb1YkE4EaU2AOnt1JXsIdV X-Received: by 2002:a05:622a:68c7:b0:42e:61ea:51f4 with SMTP id ic7-20020a05622a68c700b0042e61ea51f4mr368860qtb.10.1708657430301; Thu, 22 Feb 2024 19:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708657430; cv=none; d=google.com; s=arc-20160816; b=OohuF6TjN76VH3flYsRklyYRkzU5FKYbHDYfH0XTjEGRgG+itZEfe9CFyxbhXX9LD4 QBimVnHhKcRAEdo3zpxChCDS5U4QSRp8uwIpkJPFlTN7kXwvql1iLwfpaxGRgt0r6H9T 4UGhP1rtg/meXYwc1+46cNHAXi6PR3CvhdQ4j0fiH29rOKlGLkGFJaIgoaj1EXotggZB WdCsuf50cRHKpvaBVuROCGKPdhPFYpA+O5zGrMovR/J1bgYTbVEL3s+8gxBiN3xvCNpE y/vNNW7HeU69uAkL+SjcPvO/CNffMccUIfpEVtgMB2s1tSiiEq1nx6KZZ+E1s9n3O8nC a7/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0U9PMwHiZszNU3T0CkEUezw6dw3Df8531lwjpQDns4A=; fh=clKM80nMGOd8u5sos7YLNhrks9NjhzYwpf6dpBq72gY=; b=TRTK+MBQ+r7lX3wXor0YpH2vKWf0NMFbWffAh0qUrAOIXeqjrq/DyW+/UoR7+g8KXp fZ/h69qKNXSLcwM0URtsrRxC6lLJ14cYOqawgVoaBcYJL9c992OUgP9XjvJQ9ZMzYr5i I6zF8Y4R24lu0OyxqHBUEArxuTMO2vLA+Ew0ajpKPhsEUS0ksK2CR4/Hfz1pW5IOsT+o aSgBv5vH8vS2IoejMGmDXZiUKwb5u1Pzxph09VokA9bRU/BAv3uGPXSt1NqUAxMYfc+9 mSndJayPDLJMBu48ovS6lcMbhcfusureTUCFXfhRryG3Q0UrVtvA23bz7H1qDa8iKQ3Y QT2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BKx4zSW3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e25-20020ac84919000000b0042e4ae1f9fcsi2682468qtq.683.2024.02.22.19.03.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2024 19:03:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BKx4zSW3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdLqL-0002cX-He; Thu, 22 Feb 2024 22:03:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdLqJ-0002bn-1N for qemu-devel@nongnu.org; Thu, 22 Feb 2024 22:03:19 -0500 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdLqH-0000cZ-GD for qemu-devel@nongnu.org; Thu, 22 Feb 2024 22:03:18 -0500 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so312858a12.1 for ; Thu, 22 Feb 2024 19:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708657396; x=1709262196; darn=nongnu.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=0U9PMwHiZszNU3T0CkEUezw6dw3Df8531lwjpQDns4A=; b=BKx4zSW3MZzsNG0GXPG5NEG6dmzppnWSyeuy/Qcp+Tq8WmHFvnqbRweTTE7wEWp+cX lKtim/8+BJN8kPzJKw78NH5ue60ZLrI+6SyNltVLs515DKeZsUcCkXX5SJ0UFbOOIma3 7atWYmEmOEk9is1PJ4mW/RuO/1pDmyCq4+FmAeSxJ6jNZ/jyQh6xKjDtkobaCdn3ABxv c9vcUaXCTaDqQGEiM1uVbWp/ytV4papwFixQhGjXcVecbW+7SQH2NiE9Xb9qEqQXwzLs PpnMd1ErNqhxtljifXIZosdHwGUMZKPv4yk/6pW2vUBbfSYd5h5hv0Kaz0+aDyzk36gw Qoyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708657396; x=1709262196; 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=0U9PMwHiZszNU3T0CkEUezw6dw3Df8531lwjpQDns4A=; b=QDlMBR3Omtk6OB597gu+aoU6JMtSDs5Ex0K0ohdYxwQ9GMB6CjterIYDH3lNgWnTA2 /02tTGXdLKteBP0VOsJIJ1InthwkBnWRuJbeGnY67FQ5gSZitOanX5UnkhNeWpElMn+1 /oXX7v2nnD9oxr2gB0Kt3JI/+aI9zuHclAgHeduhdzd8VfLF/+wBwSimg4FF7/hmwBSV AKMJZPUbo1LVi9xqwjE1KGu9f+cE0XtecL1Xe3NQz/mkULBQg46TrbsfqGLDMWbK+/N9 G2TG6Nn46Mf0ClvEJzRDkSojnyy8Sc4YCkdWrMCV71wDxHSNC48gnJzMuVCJiIVdi1ZX dxhg== X-Gm-Message-State: AOJu0YzHoTVg4MCwzVlpmhsfeeWt6jdAouCCPN3pNFr52Mox2rlmUxms pl96AvfX7aHxAZIPTKPkAgXs5SwObDXAV0xhWAc+zbizSsk/cUahPPTLoYW+TXNGLObYpG6qHmI K X-Received: by 2002:a05:6a20:ce4a:b0:1a0:6c87:9197 with SMTP id id10-20020a056a20ce4a00b001a06c879197mr731687pzb.58.1708657395827; Thu, 22 Feb 2024 19:03:15 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id n38-20020a056a000d6600b006e31f615af6sm11594159pfv.17.2024.02.22.19.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 19:03:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, iii@linux.ibm.com, richard.purdie@linuxfoundation.org, mjt@tls.msk.ru Subject: [PATCH 2/3] linux-user: Add strace for shmat Date: Thu, 22 Feb 2024 17:03:08 -1000 Message-Id: <20240223030309.458451-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223030309.458451-1-richard.henderson@linaro.org> References: <20240223030309.458451-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- linux-user/strace.c | 23 +++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index cf26e55264..47d6ec3263 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -670,6 +670,25 @@ print_semctl(CPUArchState *cpu_env, const struct syscallname *name, } #endif +static void +print_shmat(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + static const struct flags shmat_flags[] = { + FLAG_GENERIC(SHM_RND), + FLAG_GENERIC(SHM_REMAP), + FLAG_GENERIC(SHM_RDONLY), + FLAG_GENERIC(SHM_EXEC), + }; + + print_syscall_prologue(name); + print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); + print_pointer(arg1, 0); + print_flags(shmat_flags, arg2, 1); + print_syscall_epilogue(name); +} + #ifdef TARGET_NR_ipc static void print_ipc(CPUArchState *cpu_env, const struct syscallname *name, @@ -683,6 +702,10 @@ print_ipc(CPUArchState *cpu_env, const struct syscallname *name, print_ipc_cmd(arg3); qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); break; + case IPCOP_shmat: + print_shmat(cpu_env, &(const struct syscallname){ .name = "shmat" }, + arg1, arg4, arg2, 0, 0, 0); + break; default: qemu_log(("%s(" TARGET_ABI_FMT_ld "," diff --git a/linux-user/strace.list b/linux-user/strace.list index 6655d4f26d..dfd4237d14 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1398,7 +1398,7 @@ { TARGET_NR_sgetmask, "sgetmask" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_shmat -{ TARGET_NR_shmat, "shmat" , NULL, NULL, print_syscall_ret_addr }, +{ TARGET_NR_shmat, "shmat" , NULL, print_shmat, print_syscall_ret_addr }, #endif #ifdef TARGET_NR_shmctl { TARGET_NR_shmctl, "shmctl" , NULL, NULL, NULL }, From patchwork Fri Feb 23 03:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 775127 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp155803wrb; Thu, 22 Feb 2024 19:03:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU+vRmQPs5zhKFY51l8ntLrVH28DB3ZVTB2tYWLCvJKPQiKa2WHXRkPdItAY+FB9GKLDYKNZ5jUefmJhb9euaJl X-Google-Smtp-Source: AGHT+IEzcMBbdqIyEKtcqbHXJl0O8SmJkMIkbdiHcACDy67j//XM8YJ8mnJZ3eHbAfB9kgYC/SZp X-Received: by 2002:a0c:9b01:0:b0:68f:6116:6f97 with SMTP id b1-20020a0c9b01000000b0068f61166f97mr1215704qve.16.1708657439699; Thu, 22 Feb 2024 19:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708657439; cv=none; d=google.com; s=arc-20160816; b=AzKqXzWtlW0HTeqYgwqbxNh8lPLu4VMAdbMxMlRc21pSC6BtT1uYppG+ggX/0bcdzI 1VHnpMmmTtZrz9IxD6NIpPvnPA2loYWiiSnjDvikd9wL4DktI92xqji38+tz1riAxhg7 dfrA9q2GbIxWbtMY85HohGrc6iONRmYk00pqkayiuEDCBNlkWQCJBgTSkIIAUUjb6qV9 RaGPPJmCUWGSAtwWPmYPUHiSlHIH/hwHiapUIYhAp/SCmEQyCbS0I++5quXN4cKYkfJy zTrDCp6ekyUHYZB280HsYXMFrI28+8TusW4ISfi0gk1n05vV7BanjZXZd6P8W4kZh/uC m7cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/sktbWKa1binb241q0r6ct6YkNzdPk613k2Pdqrs3XY=; fh=clKM80nMGOd8u5sos7YLNhrks9NjhzYwpf6dpBq72gY=; b=sFAk+OROtur9ujfXdNerQv9TpaIZTbVvFzIBa81pmFVv8W0byh5Bs9eeBZdl2XnzlR A/AhL0BH8CgTBGuvyqgtFA+ehKzZJaHS8eSYuXgThzKvzE+EsTshB/hfR96cNEGyrcEf JhIzzhzm4Pu8JQUJIeVxE/kfsZqaB5RjAol4lo0VdTbziyA6EARZDXdT6OJFa4wEcNKq irffIG3yDy9gEa6oA7YuTRot9mTNFSHeFoqqTG6rehAG+lrksVmD+X/Tmm4Y/hbKwu+P bjap4AoCYmz6FNaE7bGY36se75lqxSUKf3chzdTocO80R3jN9VG79J4Hcce4ba8jsExZ 57hA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPC2MgZm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ey6-20020a0562140b6600b0068f6008e456si11959055qvb.50.2024.02.22.19.03.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2024 19:03:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPC2MgZm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdLqN-0002d7-Tm; Thu, 22 Feb 2024 22:03:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdLqK-0002cR-QM for qemu-devel@nongnu.org; Thu, 22 Feb 2024 22:03:21 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdLqI-0000cq-Vp for qemu-devel@nongnu.org; Thu, 22 Feb 2024 22:03:20 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6e08dd0fa0bso411345b3a.1 for ; Thu, 22 Feb 2024 19:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708657397; x=1709262197; darn=nongnu.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=/sktbWKa1binb241q0r6ct6YkNzdPk613k2Pdqrs3XY=; b=WPC2MgZmL++cV5nYo1BOWU+lOWnIuzL+7gYBaqtMQqRBwe1Ycn5FUITv76VUaAUN7J R9BGClzmoYQTTsDCg9OMjP0rq0nKD9jCOZXCkmdRSPwGD0RflZ43ABWpR2Y9Q3XMgjsh 4Gck01YhqbHHsiYYyCLo4S/coJfvScaFCAUc0C0XlRaPz1nkHWX8XVmTu807l2+I/0Eu urhoorMtdRzplBRcbPDpI1v/MDTDGLy9JL8rG81ndJWhxIowx5LLMOwBfiL0vB8RchP6 Qj7AND2zlHlN0/V8ap6/H2JAnMu0gZOG5KEpkyBeMkk5BXLkbzxPgAbRJmXquSDShHoB pTpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708657397; x=1709262197; 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=/sktbWKa1binb241q0r6ct6YkNzdPk613k2Pdqrs3XY=; b=IsQjTQqAGenV7mLVPm6oGk9pblLgOSwbBcAlviZzI5SguOFj+dghxUQ3SCN/1uP2a4 pCq2+nmYIS+yVgfQiRBRqLq80otUvck0rkzBoFxBenlSd9AwWvdAnG3CFBobgT+LdpuW IsQm51VAfg50jDXOak7mtVVwxHF/QA8zrC4Axtm9QCy3qAJQ2RndvyntEBG+cLINmgO3 x1CiBwCRgT2VOnBt0KQhLA7lk806Mi+21nA3YGVb25LRkaDpODUewsJBQDkHh7izqvDl MtP8nfUbWaPF/hmCgZET84OpssVQAxllis+qGJYwLW/kI1Ovichl7iUgR7jPnVpppSpu iu7w== X-Gm-Message-State: AOJu0YyesQWAM/kI2HdG4I1c87LDVaY1AEywPv9H7MEXlKevXgj0mo21 9f97h+2fco4pnPm5pifypdnIthDvxSWOt9WZYdO3/FZjnkN5YjSDRQbOPbGYMpNtjXcQHbBo7+h m X-Received: by 2002:a05:6a00:1807:b0:6e4:8b07:1060 with SMTP id y7-20020a056a00180700b006e48b071060mr6500541pfa.14.1708657397435; Thu, 22 Feb 2024 19:03:17 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id n38-20020a056a000d6600b006e31f615af6sm11594159pfv.17.2024.02.22.19.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 19:03:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, iii@linux.ibm.com, richard.purdie@linuxfoundation.org, mjt@tls.msk.ru Subject: [PATCH 3/3] linux-user: Rewrite target_shmat Date: Thu, 22 Feb 2024 17:03:09 -1000 Message-Id: <20240223030309.458451-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223030309.458451-1-richard.henderson@linaro.org> References: <20240223030309.458451-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Handle combined host and guest alignment requirements. Handle host and guest page size differences. Handle SHM_EXEC. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/115 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Signed-off-by: Ilya Leoshkevich --- linux-user/mmap.c | 146 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 110 insertions(+), 36 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 82f4026283..29421cfab0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1236,69 +1236,143 @@ static inline abi_ulong target_shmlba(CPUArchState *cpu_env) } #endif +#if defined(__arm__) || defined(__mips__) || defined(__sparc__) +#define HOST_FORCE_SHMLBA 1 +#else +#define HOST_FORCE_SHMLBA 0 +#endif + abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, abi_ulong shmaddr, int shmflg) { CPUState *cpu = env_cpu(cpu_env); - abi_ulong raddr; struct shmid_ds shm_info; int ret; - abi_ulong shmlba; + int h_pagesize; + int t_shmlba, h_shmlba, m_shmlba; + size_t t_len, h_len, m_len; /* shmat pointers are always untagged */ - /* find out the length of the shared memory segment */ + /* + * Because we can't use host shmat() unless the address is sufficiently + * aligned for the host, we'll need to check both. + * TODO: Could be fixed with softmmu. + */ + t_shmlba = target_shmlba(cpu_env); + h_pagesize = qemu_real_host_page_size(); + h_shmlba = (HOST_FORCE_SHMLBA ? SHMLBA : h_pagesize); + m_shmlba = MAX(t_shmlba, h_shmlba); + + if (shmaddr) { + if (shmaddr & (m_shmlba - 1)) { + if (shmflg & SHM_RND) { + /* + * The guest is allowing the kernel to round the address. + * Assume that the guest is ok with us rounding to the + * host required alignment too. Anyway if we don't, we'll + * get an error from the kernel. + */ + shmaddr &= ~(m_shmlba - 1); + if (shmaddr == 0 && (shmflg & SHM_REMAP)) { + return -TARGET_EINVAL; + } + } else { + int require = TARGET_PAGE_SIZE; +#ifdef TARGET_FORCE_SHMLBA + require = t_shmlba; +#endif + /* + * Include host required alignment, as otherwise we cannot + * use host shmat at all. + */ + require = MAX(require, h_shmlba); + if (shmaddr & (require - 1)) { + return -TARGET_EINVAL; + } + } + } + } else { + if (shmflg & SHM_REMAP) { + return -TARGET_EINVAL; + } + } + /* All rounding now manually concluded. */ + shmflg &= ~SHM_RND; + + /* Find out the length of the shared memory segment. */ ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info)); if (is_error(ret)) { /* can't get length, bail out */ return ret; } + t_len = TARGET_PAGE_ALIGN(shm_info.shm_segsz); + h_len = ROUND_UP(shm_info.shm_segsz, h_pagesize); + m_len = MAX(t_len, h_len); - shmlba = target_shmlba(cpu_env); - - if (shmaddr & (shmlba - 1)) { - if (shmflg & SHM_RND) { - shmaddr &= ~(shmlba - 1); - } else { - return -TARGET_EINVAL; - } - } - if (!guest_range_valid_untagged(shmaddr, shm_info.shm_segsz)) { + if (!guest_range_valid_untagged(shmaddr, m_len)) { return -TARGET_EINVAL; } WITH_MMAP_LOCK_GUARD() { - void *host_raddr; + void *host_raddr, *test; abi_ulong last; - if (shmaddr) { - host_raddr = shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg); - } else { - abi_ulong mmap_start; - - /* In order to use the host shmat, we need to honor host SHMLBA. */ - mmap_start = mmap_find_vma(0, shm_info.shm_segsz, - MAX(SHMLBA, shmlba)); - - if (mmap_start == -1) { + if (!shmaddr) { + shmaddr = mmap_find_vma(0, m_len, m_shmlba); + if (shmaddr == -1) { return -TARGET_ENOMEM; } - host_raddr = shmat(shmid, g2h_untagged(mmap_start), - shmflg | SHM_REMAP); + } else if (!(shmflg & SHM_REMAP)) { + if (!page_check_range_empty(shmaddr, shmaddr + m_len - 1)) { + return -TARGET_EINVAL; + } + } else if (t_len < h_len) { + /* + * ??? If the host page size is larger than host page size, + * then we might be mapping more pages than the guest expects. + * TODO: Could be fixed with softmmu. + */ + if (!page_check_range_empty(shmaddr + t_len, shmaddr + h_len - 1)) { + return -TARGET_EINVAL; + } } - if (host_raddr == (void *)-1) { - return get_errno(-1); - } - raddr = h2g(host_raddr); - last = raddr + shm_info.shm_segsz - 1; + /* All placement now manually completed. */ + host_raddr = (void *)g2h_untagged(shmaddr); + test = shmat(shmid, host_raddr, shmflg | SHM_REMAP); - page_set_flags(raddr, last, + if (test != MAP_FAILED && t_len > h_len) { + /* + * The target page size is larger than the host page size. + * Fill in the final target page with anonymous memory. + */ + void *t2 = mmap(host_raddr + h_len, t_len - h_len, + PROT_READ | (shmflg & SHM_RDONLY ? 0 : PROT_WRITE), + MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0); + if (t2 == MAP_FAILED) { + test = MAP_FAILED; + } + } + + if (test == MAP_FAILED) { + ret = get_errno(-1); + if (!(shmflg & SHM_REMAP)) { + do_munmap(host_raddr, m_len); + } + return ret; + } + + assert(test == host_raddr); + last = shmaddr + m_len - 1; + + page_set_flags(shmaddr, last, PAGE_VALID | PAGE_RESET | PAGE_READ | - (shmflg & SHM_RDONLY ? 0 : PAGE_WRITE)); + (shmflg & SHM_RDONLY ? 0 : PAGE_WRITE) | + (shmflg & SHM_EXEC ? PAGE_EXEC : 0)); - shm_region_rm_complete(raddr, last); - shm_region_add(raddr, last); + shm_region_rm_complete(shmaddr, last); + shm_region_add(shmaddr, last); } /* @@ -1312,7 +1386,7 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, tb_flush(cpu); } - return raddr; + return shmaddr; } abi_long target_shmdt(abi_ulong shmaddr)