From patchwork Thu Feb 16 02:57:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 653975 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp119300wrr; Wed, 15 Feb 2023 19:01:18 -0800 (PST) X-Google-Smtp-Source: AK7set927IZ6jBGQ8FA5huBayHvYonzifK/sIls34Ar6ecqYsvgt1GgYfSBEBBK16BLHY2xD9gkV X-Received: by 2002:ad4:5ba9:0:b0:56e:f8e4:cba8 with SMTP id 9-20020ad45ba9000000b0056ef8e4cba8mr1047312qvq.34.1676516478532; Wed, 15 Feb 2023 19:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676516478; cv=none; d=google.com; s=arc-20160816; b=zr/MsKjInf26zHUzRuzxR7d0ImQLk/Pwe7kjTWrl4Ci4RYsik9A2iv2bH/P3wrcZoU QuKwj7mDfiG/EY+tXsUVu5zVomcHjufBzmVi5ZatYnyd08Ou5XFsI00L+JlrOgpQ69Zi sYPvYFNlQt76Sutr43NlJsiTqKvwRpYkO9ta14YRT/1l2l68gGACerpNAifh4SMe6xww njCi+5qHysALaUP/18WorI1QafcTEl5LrZKMJEFgRgPS3Dy6HWAVHy6pfupKvKSRoJAC bo1FNRxIg9ja/3KKLn+jhiLftzG0H+ZGETS2B5/Gkfzpg0VJ8tC88qFZEg5YW57CSCwn Lc3A== 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:to:from :dkim-signature; bh=jzoBh6h+eW5YyC2mEGGgFAPiTTpJh3Si9+ZlAorRV5U=; b=aQ2Sz2WqEcPylBhTt1AUArtggVsVf0Kk12vpcqJd/vzXUGKGQ6qtLvjuYM5UHy5Dd/ gbwfhCPbMC2y2alT35aAOH5wQdnIDPTW3Gq+GOPYpQ4DmW9QZ3oQjvBG0WwjmTizjpII +f9RpHFv4sN97gXU7quyikBChghi1Bt0zq+rW9Io2cgNg3o06gKOX13su4mkNU7QhkN4 osCaeuha7LWoZ93j8ZM7+PXqHLR0jUtptdPPak0DadUuVZvBMTiRH1UzUK50SMJ+0FY9 y5WWcmgrBpv8vcBkUJN+6eU0XafjK9+yu1lp1mY5+2dC6kAmiJrVthwD8HM4T7rxPswK IMUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pl5w9+qS; 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 s27-20020a0cb31b000000b0056ea96c47ccsi107356qve.228.2023.02.15.19.01.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 19:01:18 -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=Pl5w9+qS; 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 1pSUT1-0003OC-GS; Wed, 15 Feb 2023 21:57:51 -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 1pSUSy-0003Ne-IV for qemu-devel@nongnu.org; Wed, 15 Feb 2023 21:57:49 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSUSw-0005UJ-OH for qemu-devel@nongnu.org; Wed, 15 Feb 2023 21:57:48 -0500 Received: by mail-pg1-x530.google.com with SMTP id r18so399606pgr.12 for ; Wed, 15 Feb 2023 18:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jzoBh6h+eW5YyC2mEGGgFAPiTTpJh3Si9+ZlAorRV5U=; b=Pl5w9+qSdp9zQZeai32JyzgTY+SsukJgIIaB9000wcPRoziThkVPIbxhVATiq9F/TA yHcZPbtsHcHOEKs2bLSZMzyukFU8iWMVoHgYrIpEubYcLTGWDOS9bwUHujmHqHqgEyZe hTzTUZJYgKTYW0pAz7tjPUzxZkGk2mXH35rJIsHx1y22ogWXGGU89Q7BwJxdBoXb+VJn ACqI+AZKEm9pKPgL4yQhucFywJnPOQmBbKemjPl7wEye/7LlLzmVLmPWQacKi1gkwwO/ 38i2yDhWXTcNUft2h2gpTfBA6uTgBSolFDbehyxGaWITfCWCGkRIfLeksJJOUO9V9ULJ tjaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jzoBh6h+eW5YyC2mEGGgFAPiTTpJh3Si9+ZlAorRV5U=; b=noHZGBAncJ+CUYeHspeN4Nff/bByNQK1El0IykdnGZBumjbLtTUmycirVI1xynoPjk eIKoStCegzH4CrWBPYCWtUf7cbPecOUMDViYRdlGht1TqSazHJ0Sa5Lm94yxF5DWioUl 0II/iy3/HQTmJOkB8XFbs8Uf63BNS3ptr4CalmnpaUeZe8IZxGqNnlY1ik21HUgMMhK9 NBEjmOKl7k9FcxFZSU0iRmjVN6XTjTD10O3G7f3htJEPoQ/8zUwX+7IxRBRslFj42LV1 32116KqJ5zRuBtn+/9vrQYqht5Nn+cHx6GKu+KD8VDm5yXK7WivySOrlt/fOhQlO+NVG Bpow== X-Gm-Message-State: AO0yUKWvX3hXrBK8dhNCXBl7BOg2XYJo8qim6ky8TZQSOws1JdyNND6G h9Y9wiIktTy5kBRa630cRhgUn3L3xG87Cj1hKSk= X-Received: by 2002:a62:27c5:0:b0:5a8:a138:9a82 with SMTP id n188-20020a6227c5000000b005a8a1389a82mr3461007pfn.24.1676516265291; Wed, 15 Feb 2023 18:57:45 -0800 (PST) Received: from stoup.. (rrcs-74-87-59-234.west.biz.rr.com. [74.87.59.234]) by smtp.gmail.com with ESMTPSA id e14-20020a62aa0e000000b005a816b7c3e8sm89655pff.24.2023.02.15.18.57.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 18:57:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/30] include/exec/memop: Add bits describing atomicity Date: Wed, 15 Feb 2023 16:57:11 -1000 Message-Id: <20230216025739.1211680-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216025739.1211680-1-richard.henderson@linaro.org> References: <20230216025739.1211680-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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 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 These bits may be used to describe the precise atomicity requirements of the guest, which may then be used to constrain the methods by which it may be emulated by the host. For instance, the AArch64 LDP (32-bit) instruction changes semantics with ARMv8.4 LSE2, from MO_64 | MO_ATMAX_4 | MO_ATOM_IFALIGN (64-bits, single-copy atomic only on 4 byte units, nonatomic if not aligned by 4), to MO_64 | MO_ATMAX_SIZE | MO_ATOM_WITHIN16 (64-bits, single-copy atomic within a 16 byte block) The former may be implemented with two 4 byte loads, or a single 8 byte load if that happens to be efficient on the host. The latter may not, and may also require a helper when misaligned. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- include/exec/memop.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/exec/memop.h b/include/exec/memop.h index 25d027434a..04e4048f0b 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -81,6 +81,42 @@ typedef enum MemOp { MO_ALIGN_32 = 5 << MO_ASHIFT, MO_ALIGN_64 = 6 << MO_ASHIFT, + /* + * MO_ATOM_* describes that atomicity requirements of the operation: + * MO_ATOM_IFALIGN: the operation must be single-copy atomic if and + * only if it is aligned; if unaligned there is no atomicity. + * MO_ATOM_NONE: the operation has no atomicity requirements. + * MO_ATOM_SUBALIGN: the operation is single-copy atomic by parts + * by the alignment. E.g. if the address is 0 mod 4, then each + * 4-byte subobject is single-copy atomic. + * This is the atomicity of IBM Power and S390X processors. + * MO_ATOM_WITHIN16: the operation is single-copy atomic, even if it + * is unaligned, so long as it does not cross a 16-byte boundary; + * if it crosses a 16-byte boundary there is no atomicity. + * This is the atomicity of Arm FEAT_LSE2. + * + * MO_ATMAX_* describes the maximum atomicity unit required: + * MO_ATMAX_SIZE: the entire operation, i.e. MO_SIZE. + * MO_ATMAX_[248]: units of N bytes. + * + * Note the default (i.e. 0) values are single-copy atomic to the + * size of the operation, if aligned. This retains the behaviour + * from before these were introduced. + */ + MO_ATOM_SHIFT = 8, + MO_ATOM_MASK = 0x3 << MO_ATOM_SHIFT, + MO_ATOM_IFALIGN = 0 << MO_ATOM_SHIFT, + MO_ATOM_NONE = 1 << MO_ATOM_SHIFT, + MO_ATOM_SUBALIGN = 2 << MO_ATOM_SHIFT, + MO_ATOM_WITHIN16 = 3 << MO_ATOM_SHIFT, + + MO_ATMAX_SHIFT = 10, + MO_ATMAX_MASK = 0x3 << MO_ATMAX_SHIFT, + MO_ATMAX_SIZE = 0 << MO_ATMAX_SHIFT, + MO_ATMAX_2 = 1 << MO_ATMAX_SHIFT, + MO_ATMAX_4 = 2 << MO_ATMAX_SHIFT, + MO_ATMAX_8 = 3 << MO_ATMAX_SHIFT, + /* Combinations of the above, for ease of use. */ MO_UB = MO_8, MO_UW = MO_16,