From nobody Thu Sep 19 01:57:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1719323548; cv=none; d=zohomail.com; s=zohoarc; b=V16mkXq9+57PCTIJUcwluVoiOFIwBU3y17sXOiuMEHzD2KA0szWHsNZnNG/GWF7fBeLOLwSO0qTI50V77y6CM8WOKa6O9taIwVBWOHDk7EMITFzBljubqmAhwVRKVTpLdPw3+nFutfbDdJ1+ex2lv7lhBcGN7nOFrhL0x8NDmOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719323548; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NQmPQb13oFtw7Zjr+EpKt2RGh54SRf+k/JDvX9Bcyjo=; b=dLntr3H/EWHeeC1J3zuUtR+XJf+8ncJVYeUqw99fceq+irTTjI/qltgyOpVYRiTNaW+iM94uRvj/+vt0F5liVPgSqrL8MTs5YvLH+bDdc9Uycm74RWDhlSFGNOAX+u/8lE0aSi9h3fXwClg8d+CkeKNOOAj0FNDPfCiyUSuklJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1719323548538687.1912729805778; Tue, 25 Jun 2024 06:52:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.747741.1155287 (Exim 4.92) (envelope-from ) id 1sM6ah-0000XY-Kr; Tue, 25 Jun 2024 13:52:11 +0000 Received: by outflank-mailman (output) from mailman id 747741.1155287; Tue, 25 Jun 2024 13:52:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM6ah-0000Vk-D6; Tue, 25 Jun 2024 13:52:11 +0000 Received: by outflank-mailman (input) for mailman id 747741; Tue, 25 Jun 2024 13:52:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM6af-00086j-Ev for xen-devel@lists.xenproject.org; Tue, 25 Jun 2024 13:52:09 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1ccb7121-32fa-11ef-b4bb-af5377834399; Tue, 25 Jun 2024 15:52:07 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-57d0f929f79so5223472a12.2 for ; Tue, 25 Jun 2024 06:52:07 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf560627sm521042666b.148.2024.06.25.06.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 06:52:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1ccb7121-32fa-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719323527; x=1719928327; darn=lists.xenproject.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=NQmPQb13oFtw7Zjr+EpKt2RGh54SRf+k/JDvX9Bcyjo=; b=UFFTERedeBYHrZDHVCPP4+vRhWe4eCxPT0g4ClxMtuJ5caO4wIxwfeIMY50Jzes3yv hOjAP9O7t5Ntn324cLIbZjiovav1WH3I1LHCe0+YHCBrzRaop0uULwc1z4bL2jQL+5/0 KcPAUyd72zhw3iUKp8lcFQ5Dooil8K8Ece1V8UbfrkSkiwZj+9k9PrWC6GyMPqDADx6J vyGDCDhCpknx1LriojhUAM/iJ+YqNkMZszzCVsfAeefvkiswAW25wrNpruUKs+8hRD0G 0rRE0/2UHWCxPWzmfAfGWTz8ZK+unzQw+YFBHmMT4cgIXt6HBmq968pqcBq4dggh36t+ NjQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719323527; x=1719928327; 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=NQmPQb13oFtw7Zjr+EpKt2RGh54SRf+k/JDvX9Bcyjo=; b=N4yvJFcTzdanGXDCmr2kOI6K0W7XEiN0zI8Jv76TXXvDbrzAaDxSfx6wUjnrGRaHs2 8bEMNOkdG7dAoi1aZ1ZiRpIMTrYKJ796763sHTnOpVM7UzckrLlmgtf7+assh5G39l0s 3ne6/fTryfhPeG8Bmn2VAE3xuV7gnv/YtFHneOgQFJXEs9tXxMCt4Yw3DTg1gc7bRB5o PdWj5ZzpBOCrVeJP1ogfIgs3svCJdzOokGa2rr1E8DOAmNcg0MgjrwjUIQc5pkclgdgU aQOVL8zBljBXK9SkrMJ1Ifs2J99iNlu8wR71N8wbyuKcuAHybU26QA089ZrRRAoi7wOk D5Sg== X-Gm-Message-State: AOJu0YxliD81Oc3OlCsIaED3uqggZXgd+pty/I12CUlTlNe3+3ARBSmL g8DFMGL9k+7akkxiVDSBG4i/A1xGjItH4i3b94Dflj3lq9KT5VnCdbNYRWSc X-Google-Smtp-Source: AGHT+IGw0bOwz082172cYDo31ZXm2xuhKvCxKA7NYCAsPV1WdsPwTwRMblw0I8dTE94cDj50GwpkMw== X-Received: by 2002:a17:907:c245:b0:a6e:fccb:7146 with SMTP id a640c23a62f3a-a7245b565eamr498009666b.23.1719323527039; Tue, 25 Jun 2024 06:52:07 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v13 09/10] xen/riscv: introduce ANDN_INSN Date: Tue, 25 Jun 2024 15:51:51 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1719323549684100016 Content-Type: text/plain; charset="utf-8" RISC-V does a conditional toolchain for the Zbb extension (xen/arch/riscv/rules.mk), but unconditionally uses the ANDN instruction in emulate_xchg_1_2(). Fixes: 51dabd6312c ("xen/riscv: introduce cmpxchg.h") Suggested-by: Andrew Cooper Signed-off-by: Oleksii Kurochko --- Changes in V13: - new patch --- xen/arch/riscv/include/asm/cmpxchg.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/include/asm/cmpxchg.h b/xen/arch/riscv/include/= asm/cmpxchg.h index d5e678c036..12278be577 100644 --- a/xen/arch/riscv/include/asm/cmpxchg.h +++ b/xen/arch/riscv/include/asm/cmpxchg.h @@ -18,6 +18,20 @@ : "r" (new) \ : "memory" ); =20 +/* + * Binutils < 2.37 doesn't understand ANDN. If the toolchain is too +ld, form + * it of a NOT+AND pair + */ +#ifdef __riscv_zbb +#define ANDN_INSN(rd, rs1, rs2) \ + "andn " rd ", " rs1 ", " rs2 "\n" +#else +#define ANDN_INSN(rd, rs1, rs2) \ + "not " rd ", " rs2 "\n" \ + "and " rd ", " rs1 ", " rd "\n" +#endif + /* * For LR and SC, the A extension requires that the address held in rs1 be * naturally aligned to the size of the operand (i.e., eight-byte aligned @@ -48,7 +62,7 @@ \ asm volatile ( \ "0: lr.w" lr_sfx " %[old], %[ptr_]\n" \ - " andn %[scratch], %[old], %[mask]\n" \ + ANDN_INSN("%[scratch]", "%[old]", "%[mask]") \ " or %[scratch], %[scratch], %z[new_]\n" \ " sc.w" sc_sfx " %[scratch], %[scratch], %[ptr_]\n" \ " bnez %[scratch], 0b\n" \ --=20 2.45.2