From patchwork Wed Mar 3 17:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C3E3C433DB for ; Wed, 3 Mar 2021 23:34:53 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE29F64F1A for ; Wed, 3 Mar 2021 23:34:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE29F64F1A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4DmMSu5X78BfmKMtsPeifZgkP+ZRn1SyADrE6/VHcoM=; b=B6brPv+duPvhFJtAS97Tot9ot H0RiD4YGM03nPaz0RTW6nNKbs0qoMVBnyTjYwfCrHQztX0OK7Ic9ALIX9wwBEMXcCzGD4JR4TeEIE ZRO3LD2gtFKpE90MKOqy/Ku7vdlLdFE0vFK3kEzudo+mIaviCgSQbiQujA9tfvjaUX55Lp1H2z4Cx lsb+MN8IlhmYt6BWnMg9D4TR3uYP4MABqyca6ZcSszgADQOQDZ/9PseFCXlqOttop/GF9RIIMF12X ijcCWru74kOv93YhD7gEj+ENfR4h/E4EXcuVJkX+eYJsvrnLu5qfV+B5K3EwZ1eicYRU72s4mIU5B 6/NtlZBnw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHawx-006xy4-D7; Wed, 03 Mar 2021 23:30:39 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUxw-005jMA-72 for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oHe2UJa1GV9gPMlI4OtQnGzo32yVsNBjDhNRhl7PBJM=; b=hO73wbCnSzUE/lszniz7wtLLqybztGTnXdTdZkOVDh2GkMLDcjiihdQhuYAehhMKMpMHdf qanyAtlgpv1hca0Lh1VVN3fd3eW9v7tV/GzK2hAP7f/ae6OXEgzE4x8V9bJlgYTamykKbt +3HOZAb4PAOj/9RcVBR3mikcbXmxgTE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-cJ5PsgpKPMC257KwpvLRdQ-1; Wed, 03 Mar 2021 12:05:43 -0500 X-MC-Unique: cJ5PsgpKPMC257KwpvLRdQ-1 Received: by mail-wm1-f70.google.com with SMTP id w10so2035654wmk.1 for ; Wed, 03 Mar 2021 09:05:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oHe2UJa1GV9gPMlI4OtQnGzo32yVsNBjDhNRhl7PBJM=; b=YCnFLaNw4LZnOlFdvwQFk4xfNa/4ZQvXu+YfBpkTmiL43c2W9Pu5eTAM14pTbmu8Il 10k73YsnzT6ngFdLcibK4ymYO12tJekq8qR1O/fs4YjdHcuGLTWI3QohjuzK4yXYUl0x 1ABfczTPuJrNwnIQffOlH7Vsie9+R7DrxytY8407UJud6K7m4gyUoijk9c0vn+cOxID7 xW8C6p+b8X/TfM6v+LVz5OdMGvYgjdrHDlaW+gfVbYIjGjYk3rXnV7gyuEogm1Lgxyzv jn7FN23OPHR8XF4BdJ8mNvAPN5BKKm4MFA8HdohsZO2BLYjb8hsal9fd2kUYGTKHqZDL nq6g== X-Gm-Message-State: AOAM530ROen+bws91ZfJdJr2Y80G3pDC4TqmM9d08iWv50TVtnAPadOC eKfpjalDquoeoUX36T1NlpcNqvpL5OS/UnZZ8uW0VZdtyZNCskbUM09c6yzvSNMlzXR5MBpDz0J FlnGyxPTHZ9R9AOZhEKkejJurzVZMx2IEx+k= X-Received: by 2002:a7b:c341:: with SMTP id l1mr10593wmj.182.1614791142186; Wed, 03 Mar 2021 09:05:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjyAsbsHeWq0MALIF5czDTtQu+0Xg/zXijcZm/QhWaRy5zPghx7K2ZvxfHAPoC5ZZSS9OPTQ== X-Received: by 2002:a7b:c341:: with SMTP id l1mr10583wmj.182.1614791141988; Wed, 03 Mar 2021 09:05:41 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:05:41 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 1/8] arm64: Move patching utilities out of instruction encoding/decoding Date: Wed, 3 Mar 2021 18:05:29 +0100 Message-Id: <20210303170536.1838032-2-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Files insn.[c|h] containt some functions used for instruction patching. In order to reuse the instruction encoder/decoder, move the patching utilities to their own file. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/insn.h | 5 - arch/arm64/include/asm/patching.h | 13 +++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/ftrace.c | 1 + arch/arm64/kernel/insn.c | 149 +----------------------------- arch/arm64/kernel/jump_label.c | 1 + arch/arm64/kernel/patching.c | 148 +++++++++++++++++++++++++++++ arch/arm64/kernel/traps.c | 1 + 8 files changed, 168 insertions(+), 152 deletions(-) create mode 100644 arch/arm64/include/asm/patching.h create mode 100644 arch/arm64/kernel/patching.c diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index 4ebb9c054ccc..7437b7e7e7eb 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -379,8 +379,6 @@ static inline bool aarch64_insn_is_adr_adrp(u32 insn) return aarch64_insn_is_adr(insn) || aarch64_insn_is_adrp(insn); } -int aarch64_insn_read(void *addr, u32 *insnp); -int aarch64_insn_write(void *addr, u32 insn); enum aarch64_insn_encoding_class aarch64_get_insn_class(u32 insn); bool aarch64_insn_uses_literal(u32 insn); bool aarch64_insn_is_branch(u32 insn); @@ -487,9 +485,6 @@ u32 aarch64_insn_gen_prefetch(enum aarch64_insn_register base, s32 aarch64_get_branch_offset(u32 insn); u32 aarch64_set_branch_offset(u32 insn, s32 offset); -int aarch64_insn_patch_text_nosync(void *addr, u32 insn); -int aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt); - s32 aarch64_insn_adrp_get_offset(u32 insn); u32 aarch64_insn_adrp_set_offset(u32 insn, s32 offset); diff --git a/arch/arm64/include/asm/patching.h b/arch/arm64/include/asm/patching.h new file mode 100644 index 000000000000..6bf5adc56295 --- /dev/null +++ b/arch/arm64/include/asm/patching.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_PATCHING_H +#define __ASM_PATCHING_H + +#include + +int aarch64_insn_read(void *addr, u32 *insnp); +int aarch64_insn_write(void *addr, u32 insn); + +int aarch64_insn_patch_text_nosync(void *addr, u32 insn); +int aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt); + +#endif /* __ASM_PATCHING_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index ed65576ce710..790af8c69338 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -17,7 +17,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ return_address.o cpuinfo.o cpu_errata.o \ cpufeature.o alternative.o cacheinfo.o \ smp.o smp_spin_table.o topology.o smccc-call.o \ - syscall.o proton-pack.o idreg-override.o + syscall.o proton-pack.o idreg-override.o patching.o targets += efi-entry.o diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index 86a5cf9bc19a..fd7993f0c9c4 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef CONFIG_DYNAMIC_FTRACE /* diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index 6c0de2f60ea9..952e7d6fe60e 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -7,21 +7,14 @@ */ #include #include -#include -#include -#include -#include -#include -#include +#include +#include #include -#include -#include #include -#include +#include #include #include -#include #define AARCH64_INSN_SF_BIT BIT(31) #define AARCH64_INSN_N_BIT BIT(22) @@ -83,81 +76,6 @@ bool aarch64_insn_is_branch_imm(u32 insn) aarch64_insn_is_bcond(insn)); } -static DEFINE_RAW_SPINLOCK(patch_lock); - -static bool is_exit_text(unsigned long addr) -{ - /* discarded with init text/data */ - return system_state < SYSTEM_RUNNING && - addr >= (unsigned long)__exittext_begin && - addr < (unsigned long)__exittext_end; -} - -static bool is_image_text(unsigned long addr) -{ - return core_kernel_text(addr) || is_exit_text(addr); -} - -static void __kprobes *patch_map(void *addr, int fixmap) -{ - unsigned long uintaddr = (uintptr_t) addr; - bool image = is_image_text(uintaddr); - struct page *page; - - if (image) - page = phys_to_page(__pa_symbol(addr)); - else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) - page = vmalloc_to_page(addr); - else - return addr; - - BUG_ON(!page); - return (void *)set_fixmap_offset(fixmap, page_to_phys(page) + - (uintaddr & ~PAGE_MASK)); -} - -static void __kprobes patch_unmap(int fixmap) -{ - clear_fixmap(fixmap); -} -/* - * In ARMv8-A, A64 instructions have a fixed length of 32 bits and are always - * little-endian. - */ -int __kprobes aarch64_insn_read(void *addr, u32 *insnp) -{ - int ret; - __le32 val; - - ret = copy_from_kernel_nofault(&val, addr, AARCH64_INSN_SIZE); - if (!ret) - *insnp = le32_to_cpu(val); - - return ret; -} - -static int __kprobes __aarch64_insn_write(void *addr, __le32 insn) -{ - void *waddr = addr; - unsigned long flags = 0; - int ret; - - raw_spin_lock_irqsave(&patch_lock, flags); - waddr = patch_map(addr, FIX_TEXT_POKE0); - - ret = copy_to_kernel_nofault(waddr, &insn, AARCH64_INSN_SIZE); - - patch_unmap(FIX_TEXT_POKE0); - raw_spin_unlock_irqrestore(&patch_lock, flags); - - return ret; -} - -int __kprobes aarch64_insn_write(void *addr, u32 insn) -{ - return __aarch64_insn_write(addr, cpu_to_le32(insn)); -} - bool __kprobes aarch64_insn_uses_literal(u32 insn) { /* ldr/ldrsw (literal), prfm */ @@ -187,67 +105,6 @@ bool __kprobes aarch64_insn_is_branch(u32 insn) aarch64_insn_is_bcond(insn); } -int __kprobes aarch64_insn_patch_text_nosync(void *addr, u32 insn) -{ - u32 *tp = addr; - int ret; - - /* A64 instructions must be word aligned */ - if ((uintptr_t)tp & 0x3) - return -EINVAL; - - ret = aarch64_insn_write(tp, insn); - if (ret == 0) - __flush_icache_range((uintptr_t)tp, - (uintptr_t)tp + AARCH64_INSN_SIZE); - - return ret; -} - -struct aarch64_insn_patch { - void **text_addrs; - u32 *new_insns; - int insn_cnt; - atomic_t cpu_count; -}; - -static int __kprobes aarch64_insn_patch_text_cb(void *arg) -{ - int i, ret = 0; - struct aarch64_insn_patch *pp = arg; - - /* The first CPU becomes master */ - if (atomic_inc_return(&pp->cpu_count) == 1) { - for (i = 0; ret == 0 && i < pp->insn_cnt; i++) - ret = aarch64_insn_patch_text_nosync(pp->text_addrs[i], - pp->new_insns[i]); - /* Notify other processors with an additional increment. */ - atomic_inc(&pp->cpu_count); - } else { - while (atomic_read(&pp->cpu_count) <= num_online_cpus()) - cpu_relax(); - isb(); - } - - return ret; -} - -int __kprobes aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt) -{ - struct aarch64_insn_patch patch = { - .text_addrs = addrs, - .new_insns = insns, - .insn_cnt = cnt, - .cpu_count = ATOMIC_INIT(0), - }; - - if (cnt <= 0) - return -EINVAL; - - return stop_machine_cpuslocked(aarch64_insn_patch_text_cb, &patch, - cpu_online_mask); -} - static int __kprobes aarch64_get_imm_shift_mask(enum aarch64_insn_imm_type type, u32 *maskp, int *shiftp) { diff --git a/arch/arm64/kernel/jump_label.c b/arch/arm64/kernel/jump_label.c index 9a8a0ae1e75f..fc98037e1220 100644 --- a/arch/arm64/kernel/jump_label.c +++ b/arch/arm64/kernel/jump_label.c @@ -8,6 +8,7 @@ #include #include #include +#include void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type) diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c new file mode 100644 index 000000000000..9d050e33901b --- /dev/null +++ b/arch/arm64/kernel/patching.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static DEFINE_RAW_SPINLOCK(patch_lock); + +static bool is_exit_text(unsigned long addr) +{ + /* discarded with init text/data */ + return system_state < SYSTEM_RUNNING && + addr >= (unsigned long)__exittext_begin && + addr < (unsigned long)__exittext_end; +} + +static bool is_image_text(unsigned long addr) +{ + return core_kernel_text(addr) || is_exit_text(addr); +} + +static void __kprobes *patch_map(void *addr, int fixmap) +{ + unsigned long uintaddr = (uintptr_t) addr; + bool image = is_image_text(uintaddr); + struct page *page; + + if (image) + page = phys_to_page(__pa_symbol(addr)); + else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) + page = vmalloc_to_page(addr); + else + return addr; + + BUG_ON(!page); + return (void *)set_fixmap_offset(fixmap, page_to_phys(page) + + (uintaddr & ~PAGE_MASK)); +} + +static void __kprobes patch_unmap(int fixmap) +{ + clear_fixmap(fixmap); +} +/* + * In ARMv8-A, A64 instructions have a fixed length of 32 bits and are always + * little-endian. + */ +int __kprobes aarch64_insn_read(void *addr, u32 *insnp) +{ + int ret; + __le32 val; + + ret = copy_from_kernel_nofault(&val, addr, AARCH64_INSN_SIZE); + if (!ret) + *insnp = le32_to_cpu(val); + + return ret; +} + +static int __kprobes __aarch64_insn_write(void *addr, __le32 insn) +{ + void *waddr = addr; + unsigned long flags = 0; + int ret; + + raw_spin_lock_irqsave(&patch_lock, flags); + waddr = patch_map(addr, FIX_TEXT_POKE0); + + ret = copy_to_kernel_nofault(waddr, &insn, AARCH64_INSN_SIZE); + + patch_unmap(FIX_TEXT_POKE0); + raw_spin_unlock_irqrestore(&patch_lock, flags); + + return ret; +} + +int __kprobes aarch64_insn_write(void *addr, u32 insn) +{ + return __aarch64_insn_write(addr, cpu_to_le32(insn)); +} + +int __kprobes aarch64_insn_patch_text_nosync(void *addr, u32 insn) +{ + u32 *tp = addr; + int ret; + + /* A64 instructions must be word aligned */ + if ((uintptr_t)tp & 0x3) + return -EINVAL; + + ret = aarch64_insn_write(tp, insn); + if (ret == 0) + __flush_icache_range((uintptr_t)tp, + (uintptr_t)tp + AARCH64_INSN_SIZE); + + return ret; +} + +struct aarch64_insn_patch { + void **text_addrs; + u32 *new_insns; + int insn_cnt; + atomic_t cpu_count; +}; + +static int __kprobes aarch64_insn_patch_text_cb(void *arg) +{ + int i, ret = 0; + struct aarch64_insn_patch *pp = arg; + + /* The first CPU becomes master */ + if (atomic_inc_return(&pp->cpu_count) == 1) { + for (i = 0; ret == 0 && i < pp->insn_cnt; i++) + ret = aarch64_insn_patch_text_nosync(pp->text_addrs[i], + pp->new_insns[i]); + /* Notify other processors with an additional increment. */ + atomic_inc(&pp->cpu_count); + } else { + while (atomic_read(&pp->cpu_count) <= num_online_cpus()) + cpu_relax(); + isb(); + } + + return ret; +} + +int __kprobes aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt) +{ + struct aarch64_insn_patch patch = { + .text_addrs = addrs, + .new_insns = insns, + .insn_cnt = cnt, + .cpu_count = ATOMIC_INIT(0), + }; + + if (cnt <= 0) + return -EINVAL; + + return stop_machine_cpuslocked(aarch64_insn_patch_text_cb, &patch, + cpu_online_mask); +} diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index a05d34f0e82a..d7057e307bca 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include From patchwork Wed Mar 3 17:05:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE21BC433E0 for ; Wed, 3 Mar 2021 23:35:46 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCF0764F14 for ; Wed, 3 Mar 2021 23:35:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCF0764F14 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=K+V/OrJbasyqCDcCGeT+lYbDjj7BIbNmYtbRa0x4O2E=; b=kWnh3r4XL2Tcxfqmi50GXLWFB xWUf+eR2JSX+GI1Szj224xfN/Cmo2vRui3lCbUtOVp9aERYiNk/Cfk2YZZ5GtDJ50FGjsTxYbrreu Mh7kDESvccOQL0//yAvigbp0yomgKEH9aoAZ5aXahr08HEeK7BUjWwjDiotRIgEIXDqL6AzBR290L NP1lS1xjxf6ekZNnnDr3WUyTSCPpXIe4+SwtzXMOti82fNwEdh/zfNbAMq1JtQqHnZpE1CSC3heTU CxQnEMDD5juMilPJeoNMxgHDC8R8+vX8i9ELMZW10MqqYJz8kNQFhUL6cVUIudX4uK6kbN2hM5+Kn pHqSEQWlQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHaxi-006y8Z-KA; Wed, 03 Mar 2021 23:31:27 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUxw-005jMG-22 for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/vE76ypT+y/+5pQJJOf6TQekKJTWzPC+T2W1EkSpYk=; b=IqgH2p/oBNd/Jkm8JSCjFS+v1dnoBuTxNHyii57+CEbGGJ0n6tPWwN78hdTb1n4y2jwg+b aJxKXWckhsDGr2HavM+vBxpCoX424dLVS5XvAvI/KYiwBayem1gv87eIkWwi7dCU4PG0Tx moPdb9mRQitjDJGm2DvfY9ZNx5J/mxs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-599-nzxIiyM6NDSGNxi1H5Cpvg-1; Wed, 03 Mar 2021 12:05:47 -0500 X-MC-Unique: nzxIiyM6NDSGNxi1H5Cpvg-1 Received: by mail-wm1-f70.google.com with SMTP id p8so3263860wmq.7 for ; Wed, 03 Mar 2021 09:05:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l/vE76ypT+y/+5pQJJOf6TQekKJTWzPC+T2W1EkSpYk=; b=Qy/ClPpWRuyjQAWugSK0GD0KIbJhfqeE4Sg1+asuw+M3KDrdfhacUjXZCXIE3LgnF2 lSTpqHHKyuGv+TS3bg8LJ2AgWEUDb2KVDJqINr3EuVcDI+R2eJerPuIU3D9/iP8EBiPA F3y/eIIAWfTN1pV8u6ed7nQs6h4rSArsSPvM5Fkac82CuzWCCOayxPh2asJdUmQUQB7g bFgi3qGPd6yvkK4vf1WI75GpmmOMfSOtfx2DfLKG9WxMgyrv3g8iV4DUmU1Fszdrs7WZ dNvZuFRLtnXYh38bcGcuNHGOnJrH3leES7Z5VaiDE/Mr40pIEDXTHUmuJYSD8NSIl+Gb SxMg== X-Gm-Message-State: AOAM533Lsl3Lv+T+KkaES+E0AWWRtnB+E93CYmGW+n+fDVxpnZrOzdLN NVQOgIZWrnSTpUWKwtPSLqHZdTVYpVOy5ixPHcYIKyitbkkxVo2ekMzihFWQ3OWdEx61jIRPT2M k92ILyJexxX4bMxsFePrWoRwhgLwpdwIxx5s= X-Received: by 2002:adf:a2c2:: with SMTP id t2mr27858275wra.47.1614791145764; Wed, 03 Mar 2021 09:05:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGBNOH4F57UqVuCyTJBRKoSzkjw7DOF9KE+Q+4TH+LKMycY/5xU/FcBzcYGoS4PdpYoDqh9Q== X-Received: by 2002:adf:a2c2:: with SMTP id t2mr27858129wra.47.1614791143481; Wed, 03 Mar 2021 09:05:43 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:05:43 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 2/8] arm64: Move aarch32 condition check functions Date: Wed, 3 Mar 2021 18:05:30 +0100 Message-Id: <20210303170536.1838032-3-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The functions to check condition flags for aarch32 execution is only used to emulate aarch32 instructions. Move them from the instruction encoding/decoding code to the trap handling files. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/insn.h | 2 - arch/arm64/include/asm/probes.h | 2 +- arch/arm64/include/asm/traps.h | 3 + arch/arm64/kernel/insn.c | 98 ----------------------- arch/arm64/kernel/probes/simulate-insn.c | 1 + arch/arm64/kernel/traps.c | 99 +++++++++++++++++++++++- 6 files changed, 103 insertions(+), 102 deletions(-) diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index 7437b7e7e7eb..14aa2f3aebfe 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -499,8 +499,6 @@ u32 aarch32_insn_extract_reg_num(u32 insn, int offset); u32 aarch32_insn_mcr_extract_opc2(u32 insn); u32 aarch32_insn_mcr_extract_crm(u32 insn); -typedef bool (pstate_check_t)(unsigned long); -extern pstate_check_t * const aarch32_opcode_cond_checks[16]; #endif /* __ASSEMBLY__ */ #endif /* __ASM_INSN_H */ diff --git a/arch/arm64/include/asm/probes.h b/arch/arm64/include/asm/probes.h index 006946745352..462ca74a94ac 100644 --- a/arch/arm64/include/asm/probes.h +++ b/arch/arm64/include/asm/probes.h @@ -7,7 +7,7 @@ #ifndef _ARM_PROBES_H #define _ARM_PROBES_H -#include +#include typedef u32 probe_opcode_t; typedef void (probes_handler_t) (u32 opcode, long addr, struct pt_regs *); diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h index 54f32a0675df..6f33ff55a9f0 100644 --- a/arch/arm64/include/asm/traps.h +++ b/arch/arm64/include/asm/traps.h @@ -100,4 +100,7 @@ static inline u32 arm64_ras_serror_get_severity(u32 esr) bool arm64_is_fatal_ras_serror(struct pt_regs *regs, unsigned int esr); void __noreturn arm64_serror_panic(struct pt_regs *regs, u32 esr); + +typedef bool (pstate_check_t)(unsigned long); +extern pstate_check_t * const aarch32_opcode_cond_checks[16]; #endif diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index 952e7d6fe60e..6ff8826ae7ea 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -1289,104 +1289,6 @@ u32 aarch32_insn_mcr_extract_crm(u32 insn) return insn & CRM_MASK; } -static bool __kprobes __check_eq(unsigned long pstate) -{ - return (pstate & PSR_Z_BIT) != 0; -} - -static bool __kprobes __check_ne(unsigned long pstate) -{ - return (pstate & PSR_Z_BIT) == 0; -} - -static bool __kprobes __check_cs(unsigned long pstate) -{ - return (pstate & PSR_C_BIT) != 0; -} - -static bool __kprobes __check_cc(unsigned long pstate) -{ - return (pstate & PSR_C_BIT) == 0; -} - -static bool __kprobes __check_mi(unsigned long pstate) -{ - return (pstate & PSR_N_BIT) != 0; -} - -static bool __kprobes __check_pl(unsigned long pstate) -{ - return (pstate & PSR_N_BIT) == 0; -} - -static bool __kprobes __check_vs(unsigned long pstate) -{ - return (pstate & PSR_V_BIT) != 0; -} - -static bool __kprobes __check_vc(unsigned long pstate) -{ - return (pstate & PSR_V_BIT) == 0; -} - -static bool __kprobes __check_hi(unsigned long pstate) -{ - pstate &= ~(pstate >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ - return (pstate & PSR_C_BIT) != 0; -} - -static bool __kprobes __check_ls(unsigned long pstate) -{ - pstate &= ~(pstate >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ - return (pstate & PSR_C_BIT) == 0; -} - -static bool __kprobes __check_ge(unsigned long pstate) -{ - pstate ^= (pstate << 3); /* PSR_N_BIT ^= PSR_V_BIT */ - return (pstate & PSR_N_BIT) == 0; -} - -static bool __kprobes __check_lt(unsigned long pstate) -{ - pstate ^= (pstate << 3); /* PSR_N_BIT ^= PSR_V_BIT */ - return (pstate & PSR_N_BIT) != 0; -} - -static bool __kprobes __check_gt(unsigned long pstate) -{ - /*PSR_N_BIT ^= PSR_V_BIT */ - unsigned long temp = pstate ^ (pstate << 3); - - temp |= (pstate << 1); /*PSR_N_BIT |= PSR_Z_BIT */ - return (temp & PSR_N_BIT) == 0; -} - -static bool __kprobes __check_le(unsigned long pstate) -{ - /*PSR_N_BIT ^= PSR_V_BIT */ - unsigned long temp = pstate ^ (pstate << 3); - - temp |= (pstate << 1); /*PSR_N_BIT |= PSR_Z_BIT */ - return (temp & PSR_N_BIT) != 0; -} - -static bool __kprobes __check_al(unsigned long pstate) -{ - return true; -} - -/* - * Note that the ARMv8 ARM calls condition code 0b1111 "nv", but states that - * it behaves identically to 0b1110 ("al"). - */ -pstate_check_t * const aarch32_opcode_cond_checks[16] = { - __check_eq, __check_ne, __check_cs, __check_cc, - __check_mi, __check_pl, __check_vs, __check_vc, - __check_hi, __check_ls, __check_ge, __check_lt, - __check_gt, __check_le, __check_al, __check_al -}; - static bool range_of_ones(u64 val) { /* Doesn't handle full ones or full zeroes */ diff --git a/arch/arm64/kernel/probes/simulate-insn.c b/arch/arm64/kernel/probes/simulate-insn.c index 25f67ec59635..22d0b3252476 100644 --- a/arch/arm64/kernel/probes/simulate-insn.c +++ b/arch/arm64/kernel/probes/simulate-insn.c @@ -10,6 +10,7 @@ #include #include +#include #include "simulate-insn.h" diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index d7057e307bca..48ff6fb888e0 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +45,104 @@ #include #include +static bool __kprobes __check_eq(unsigned long pstate) +{ + return (pstate & PSR_Z_BIT) != 0; +} + +static bool __kprobes __check_ne(unsigned long pstate) +{ + return (pstate & PSR_Z_BIT) == 0; +} + +static bool __kprobes __check_cs(unsigned long pstate) +{ + return (pstate & PSR_C_BIT) != 0; +} + +static bool __kprobes __check_cc(unsigned long pstate) +{ + return (pstate & PSR_C_BIT) == 0; +} + +static bool __kprobes __check_mi(unsigned long pstate) +{ + return (pstate & PSR_N_BIT) != 0; +} + +static bool __kprobes __check_pl(unsigned long pstate) +{ + return (pstate & PSR_N_BIT) == 0; +} + +static bool __kprobes __check_vs(unsigned long pstate) +{ + return (pstate & PSR_V_BIT) != 0; +} + +static bool __kprobes __check_vc(unsigned long pstate) +{ + return (pstate & PSR_V_BIT) == 0; +} + +static bool __kprobes __check_hi(unsigned long pstate) +{ + pstate &= ~(pstate >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ + return (pstate & PSR_C_BIT) != 0; +} + +static bool __kprobes __check_ls(unsigned long pstate) +{ + pstate &= ~(pstate >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ + return (pstate & PSR_C_BIT) == 0; +} + +static bool __kprobes __check_ge(unsigned long pstate) +{ + pstate ^= (pstate << 3); /* PSR_N_BIT ^= PSR_V_BIT */ + return (pstate & PSR_N_BIT) == 0; +} + +static bool __kprobes __check_lt(unsigned long pstate) +{ + pstate ^= (pstate << 3); /* PSR_N_BIT ^= PSR_V_BIT */ + return (pstate & PSR_N_BIT) != 0; +} + +static bool __kprobes __check_gt(unsigned long pstate) +{ + /*PSR_N_BIT ^= PSR_V_BIT */ + unsigned long temp = pstate ^ (pstate << 3); + + temp |= (pstate << 1); /*PSR_N_BIT |= PSR_Z_BIT */ + return (temp & PSR_N_BIT) == 0; +} + +static bool __kprobes __check_le(unsigned long pstate) +{ + /*PSR_N_BIT ^= PSR_V_BIT */ + unsigned long temp = pstate ^ (pstate << 3); + + temp |= (pstate << 1); /*PSR_N_BIT |= PSR_Z_BIT */ + return (temp & PSR_N_BIT) != 0; +} + +static bool __kprobes __check_al(unsigned long pstate) +{ + return true; +} + +/* + * Note that the ARMv8 ARM calls condition code 0b1111 "nv", but states that + * it behaves identically to 0b1110 ("al"). + */ +pstate_check_t * const aarch32_opcode_cond_checks[16] = { + __check_eq, __check_ne, __check_cs, __check_cc, + __check_mi, __check_pl, __check_vs, __check_vc, + __check_hi, __check_ls, __check_ge, __check_lt, + __check_gt, __check_le, __check_al, __check_al +}; + static const char *handler[] = { "Synchronous Abort", "IRQ", From patchwork Wed Mar 3 17:05:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2A9FC433E0 for ; Thu, 4 Mar 2021 00:05:10 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5767964EEE for ; Thu, 4 Mar 2021 00:05:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5767964EEE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aLxoZ0XgCMJQycj0ujSQiZO9dNpTO7lTU5D97fUg/lk=; b=V7TVN0Xtrpo6hjl3okrm+nb0w kxBtGwVKrgWOO3EIXjim+ImQk4ykV5TiFT991PBjUB+4O7SQW1pdOPkQMI+LeIbnMiTSWcbxvpv5P xW1lk9t9OQWpQL5nv7aYhtXakwR/0A7N2xnfLIj1gKAFoQgEiLfr5ui1mMNvXQIr8YsdVFo7D+zol vXpdDGY6tqEB1ubinanxQffBR/GusP0Cn4w3KY9mE09DJiGYnhZ5D/vBQYlS5nvEyWesGYL/1sAWK cr24QUPAvfVilihLHgqTlM3anyJDGisaAZAfefPFsHLNDPE4bJPne5RwAWB5y4YG3+giCuhifuXkl A/YYDipVA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHbOT-0073SA-4L; Wed, 03 Mar 2021 23:59:05 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHV33-005kKD-3v for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:12:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YzYqShpHo6c5w25CI9lpA3dmAurPMURmMoKrMzpauQQ=; b=Kffk0ALDxz4crMd0z3IUEa9HRazc9Xb2AevsO/yR1I4cy+hIbiNid+MT2ofXyYxtB6rpiJ w3yaoAzJgvRor2tAzJKJWzdpY6lS5O1jyvkPi0AJPPe0pPawoPmZamExs9LOEaLTIun5Vn IsffhokBNXmoBI/4PcEa+wUw2OL78qQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-cIszB-YFOYKGxcWlPkdyKg-1; Wed, 03 Mar 2021 12:12:29 -0500 X-MC-Unique: cIszB-YFOYKGxcWlPkdyKg-1 Received: by mail-wr1-f72.google.com with SMTP id e29so12995916wra.12 for ; Wed, 03 Mar 2021 09:12:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YzYqShpHo6c5w25CI9lpA3dmAurPMURmMoKrMzpauQQ=; b=O8dy7Lq2V7SZvGylZHveUhFmolGbS2J58cfCZjHMXfpkvCJW/ZvWVyuaXW52cgS+vF lwpokvq5u5tTz5yv84srXtLD1uvIKKWm5Tze4n03VFFVsXo7QgAcyUXhpSVSHGxVU9t2 F3zcEW9184NO1w0UNr/DZZuGFyRDQ7aEnuBkwbS/pbCjmsQ1gFhsnrswjm6sAeWDxUpP drZ/+jcdZFed6PyzgGNeWti2P7X6UqtEZGCrTtPZI9IcT/FnFJwVMS/FTBfYSQU086h1 Ug6sZG3hbcblp7oV0N1lg6AIuDYEfNVa36RzFw8oaV1QJtubqxY6yGNXY70YwkFLYw6x zKeg== X-Gm-Message-State: AOAM531H1KzxG/ef0nCzC4QKrZa0GFhXPIw5ThTQuk2jP4HJQqct/mQV L74TEBzavyf1jdWsQVKq8SK5zFxMMVCtq7h+EjlLaNaWhgkYMAcRQnHPFafPWeUJoea/iNCuA/z JKiIMhjIBuJV/V1j56tBVITx6/j3quNX7tUI= X-Received: by 2002:a1c:1d82:: with SMTP id d124mr13807wmd.1.1614791159127; Wed, 03 Mar 2021 09:05:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/w4VEMRsiBT75nmEd1w/T3n9ICG9GjGPK8ANFaXpMFx0mRKUTD31eTCQcfxUG5OuVGBVtuA== X-Received: by 2002:a1c:1d82:: with SMTP id d124mr13175wmd.1.1614791147050; Wed, 03 Mar 2021 09:05:47 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:05:46 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 3/8] arm64: insn: Reduce header dependencies of instruction decoder Date: Wed, 3 Mar 2021 18:05:31 +0100 Message-Id: <20210303170536.1838032-4-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The instruction encoder/decoder depends on alternative headers only for single macro definitions that could be part of the instruction decoder. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/alternative-macros.h | 3 --- arch/arm64/include/asm/insn.h | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h index 5df500dcc627..c01edf4d988d 100644 --- a/arch/arm64/include/asm/alternative-macros.h +++ b/arch/arm64/include/asm/alternative-macros.h @@ -6,9 +6,6 @@ #define ARM64_CB_PATCH ARM64_NCAPS -/* A64 instructions are always 32 bits. */ -#define AARCH64_INSN_SIZE 4 - #ifndef __ASSEMBLY__ #include diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index 14aa2f3aebfe..ffcdeac80026 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -10,7 +10,8 @@ #include #include -#include +/* A64 instructions are always 32 bits. */ +#define AARCH64_INSN_SIZE 4 #ifndef __ASSEMBLY__ /* From patchwork Wed Mar 3 17:05:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4EE4C433E0 for ; Wed, 3 Mar 2021 23:37:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24FAF64F23 for ; Wed, 3 Mar 2021 23:37:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24FAF64F23 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Pn5DWCSRtD3WJDzFNZNOB/WTSe/j+OApoOLR0pZu4qY=; b=M+ed0murH5bNewrjejf14l7OV rrCf6oolK8wNpBNoT6no7kL7uQx3ZU7dzq0V1qTvn/EI45b9oRAxRRYgc52Rjuvusvjk+XElnnsAc LvxHRGbZuuVv4TpMAS2a0uSZfkAr5Y0g7ngOcEcDpiYWwxDaWFiu954mltWa0GtxJrBdi4g7zKEOG MzUEnlnNnBZwHlrh5UxbOfRCWMvUPo043ApOgVh36psHmy1dwiUyyyZOGu+J6tpfVGQBMZ6IJusk8 wLvgCFIsLlZpOdvtPes2xVwV4PC+wVe5FjAL+epODawDshngimMk8lMtwY+E2CKUvUjMaaMEYNxQ/ 9zwxXIWoA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHb01-006yYK-99; Wed, 03 Mar 2021 23:33:50 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUyD-005jQw-Tw for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yk5hew9EWxKSUOJsRRgQSnvH+BMlTy0ZCJsrZVtQ1Oc=; b=TfjUPRhOQCy4GP8ARrw+C6vBzqNIiU4JZDuLQhmhm37G1ueD2NsaGzP1r7SiaY6zFjZv5e KW7unntt5bXPnOw8FTZOKAyOE4aIxeSC4z+QkDEI2iZ0lzTTmLQCqzqtBmjRuHrmtBEcQy 1N9gp4dO6ALdks1Hzcd0ccdTdtvkBy0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-569-Da7gQmKUO9GA5oBIt3aHYw-1; Wed, 03 Mar 2021 12:06:02 -0500 X-MC-Unique: Da7gQmKUO9GA5oBIt3aHYw-1 Received: by mail-wr1-f69.google.com with SMTP id e13so12988534wrg.4 for ; Wed, 03 Mar 2021 09:06:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yk5hew9EWxKSUOJsRRgQSnvH+BMlTy0ZCJsrZVtQ1Oc=; b=d9AwCDbxpwdnlvj66oN0JTuXHegpCzPqhGkIJ9wcz73JNWS8mMeNAkoHWNZhi1jnWE Vi/KJTAzuh+z9KwrGgCfuAiJcTxxBLQJ+/a2pLETGZIbyW0T3P76X1T/sHOpEyt0omGS D5/AbgYbT51YaKtMchul3yVF2O98xMYWTSFodfNlcKBwoxFw9p8CxehG9RhYPNvBH3+x 3liqN+VgYPxzL87/KPeqQuP1MHfvGPI/V3CFeHSy/5/Z6WXAM6ENHlxn2lMo5prYlm1N S9mBmvQo/kbz8hJUWlw8IuwDjpSIKgqry3gSmh+Q2isvGKU5ormHW6W3qeofM8E73WPZ PUmg== X-Gm-Message-State: AOAM531QvPLD5WKDtIu+67NsQGOYBro13Yku0WjL22Qbqm5lDVrk0PGI d8hkVJ3O94xyVHjfW4drWEutrf3bXHJOHtm0Bl7Sy0xoLiWIOZ8NUFWEtkzVR47jiSYYILm4s9l AzRchHmH54yYMOW+Gz1BasvoBBhmc7CBhT9E= X-Received: by 2002:adf:de92:: with SMTP id w18mr27975096wrl.217.1614791161391; Wed, 03 Mar 2021 09:06:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVb38s51jSJeLfyUquwBfMh6UgqoJPoyXtTvGV66gDQkofnbwtYWw0E77rPTtrMzUBW9GCjg== X-Received: by 2002:adf:de92:: with SMTP id w18mr27975085wrl.217.1614791161210; Wed, 03 Mar 2021 09:06:01 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:06:00 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 4/8] arm64: Move instruction encoder/decoder under lib/ Date: Wed, 3 Mar 2021 18:05:32 +0100 Message-Id: <20210303170536.1838032-5-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Aarch64 instruction set encoding and decoding logic can prove useful for some features/tools both part of the kernel and outside the kernel. Isolate the function dealing only with encoding/decoding instructions, with minimal dependency on kernel utilities in order to be able to reuse that code. Code was only moved, no code should have been added, removed nor modifier. Signed-off-by: Julien Thierry --- arch/arm64/kernel/Makefile | 2 +- arch/arm64/lib/Makefile | 6 +++--- arch/arm64/{kernel => lib}/insn.c | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename arch/arm64/{kernel => lib}/insn.c (100%) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 790af8c69338..027f06cb75ff 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -13,7 +13,7 @@ CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE) obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ entry-common.o entry-fpsimd.o process.o ptrace.o \ setup.o signal.o sys.o stacktrace.o time.o traps.o \ - io.o vdso.o hyp-stub.o psci.o cpu_ops.o insn.o \ + io.o vdso.o hyp-stub.o psci.o cpu_ops.o \ return_address.o cpuinfo.o cpu_errata.o \ cpufeature.o alternative.o cacheinfo.o \ smp.o smp_spin_table.o topology.o smccc-call.o \ diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index d31e1169d9b8..9cd83908717d 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 lib-y := clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ - clear_page.o csum.o memchr.o memcpy.o memmove.o \ - memset.o memcmp.o strcmp.o strncmp.o strlen.o \ - strnlen.o strchr.o strrchr.o tishift.o + clear_page.o csum.o insn.o memchr.o memcpy.o \ + memmove.o memset.o memcmp.o strcmp.o strncmp.o \ + strlen.o strnlen.o strchr.o strrchr.o tishift.o ifeq ($(CONFIG_KERNEL_MODE_NEON), y) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/lib/insn.c similarity index 100% rename from arch/arm64/kernel/insn.c rename to arch/arm64/lib/insn.c From patchwork Wed Mar 3 17:05:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C60FEC433E0 for ; Wed, 3 Mar 2021 23:38:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C7A964F25 for ; Wed, 3 Mar 2021 23:38:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C7A964F25 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AYUKaxAlTtR3G9bTMNixFbn/dIcfkem+W2Ctv6WfmDE=; b=Dq8WF5cX4wP052FgAXdtF25Hi /OvwmnTsaHGQE2pkgE9wChwHRyNn46hjGsliFWKDmEUnHW1qTQ/SqavxWgexVgyD6wyiycuPHb5IR D54jBRJDnsRHnI0a2mtxuZytzbfXClBeCvNOTgJjm9fJ2lxPTbpPKdVKP1FjIA7pPjyf7M5MfNX85 gZU0IZ3OD7zMN76q9Q0xaG1MUt4gZUQ2ASVa6tLV/0llKQNHquAxt0LaEzbW+eALfdqs22UY8orq7 TqZmoQHGkmESNpdbZZgYzJxMsC6MgEwJVnT+SB+VmHmnnsNuMJOFx1RMFuf7BQNRayJc96WHbF6j3 X8DBVAc/w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHb0p-006ylq-EZ; Wed, 03 Mar 2021 23:34:40 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUyM-005jSy-8G for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PNFPZrFga1zLopoBvYwVrfUOQSaR7zQE1lJT2SHv4Qk=; b=VX5RvCNzhRFKeKVHZ2EwjCR3zxLRhalMBSjvPmEixM2RLz9QetoXIU66ourpFREto/YlsK M7PQlKpd2mD+uJbgA85SwjnlTvC4kRmfiy77M5itpEeCUXV48e2xGAE/RmT8X0I709a1V7 kVF09EAZqFyd8rV6wUrTlznSvxDm/2s= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-qq1-hMjAPZiCE0WDS6gruA-1; Wed, 03 Mar 2021 12:06:05 -0500 X-MC-Unique: qq1-hMjAPZiCE0WDS6gruA-1 Received: by mail-wr1-f70.google.com with SMTP id l10so13013093wry.16 for ; Wed, 03 Mar 2021 09:06:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PNFPZrFga1zLopoBvYwVrfUOQSaR7zQE1lJT2SHv4Qk=; b=rd+FVvwYlcP+dNHe3YT2XJMy5D1qCANO/ZSbKRfFjGiaJ4aT6qaryF6m9mJQIPA8Ov sLaGNWOjtM0AxbFy1Kh/SDldb1uf2N98RAS3AxxL/o7AimR4bawB3DvAQ8moumND++md 1StGiaglCwpqgMZoclAavDoSWlASHXjk7FCakbXHOkpvAIlav++zR4WbjIo3uf3LZxPt AwJqkat2rVwMgOzDC7p9mN+F39ljiurKsGeLshezWHh572QSO1MdDhYqcliCQ2vnX6F6 ekYD+TY9caphudAe1sZPke3HexEUElZoUYcxL0MvyVDJ/ZaAabVHMYnLdJPej3LU0x+s CqhA== X-Gm-Message-State: AOAM531h10xql/QmKRyoMlfHlo877WpQBFlL9Qo7JTZmtUvBFpG5vSAR bbIYayt2e19TCHMI2MUyve8TVeSBrTLplv5LGc3M7DqwU8PisZdHcKhazvbtLYSxLY68pSDFLaP IzZDUlJsq3cNgv9Kd7uJb7wLJcHStwwRumQI= X-Received: by 2002:adf:a2c2:: with SMTP id t2mr27859268wra.47.1614791163794; Wed, 03 Mar 2021 09:06:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxD0v/fzNgqSwNk35vvYY+wNzFbFYn93XkQS+sDe+djtqgvt9cBoTJiWb04+lSf82I9ql7osQ== X-Received: by 2002:adf:a2c2:: with SMTP id t2mr27859256wra.47.1614791163583; Wed, 03 Mar 2021 09:06:03 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:06:03 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 5/8] arm64: insn: Add SVE instruction class Date: Wed, 3 Mar 2021 18:05:33 +0100 Message-Id: <20210303170536.1838032-6-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SVE has been public for some time now. Let the decoder acknowledge its existence. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/insn.h | 1 + arch/arm64/lib/insn.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index ffcdeac80026..b55b629c5eab 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -31,6 +31,7 @@ */ enum aarch64_insn_encoding_class { AARCH64_INSN_CLS_UNKNOWN, /* UNALLOCATED */ + AARCH64_INSN_CLS_SVE, /* SVE instructions */ AARCH64_INSN_CLS_DP_IMM, /* Data processing - immediate */ AARCH64_INSN_CLS_DP_REG, /* Data processing - register */ AARCH64_INSN_CLS_DP_FPSIMD, /* Data processing - SIMD and FP */ diff --git a/arch/arm64/lib/insn.c b/arch/arm64/lib/insn.c index 6ff8826ae7ea..b506a4b1e38c 100644 --- a/arch/arm64/lib/insn.c +++ b/arch/arm64/lib/insn.c @@ -23,7 +23,7 @@ static const int aarch64_insn_encoding_class[] = { AARCH64_INSN_CLS_UNKNOWN, AARCH64_INSN_CLS_UNKNOWN, - AARCH64_INSN_CLS_UNKNOWN, + AARCH64_INSN_CLS_SVE, AARCH64_INSN_CLS_UNKNOWN, AARCH64_INSN_CLS_LDST, AARCH64_INSN_CLS_DP_REG, From patchwork Wed Mar 3 17:05:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F57DC433DB for ; Wed, 3 Mar 2021 23:43:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 031BB60C41 for ; Wed, 3 Mar 2021 23:43:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 031BB60C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RN/9WR6aXV6EowcBqh8zZtK9+OYhch7Co9TtBOKNYeY=; b=dcZiqB7Q6GA0CFRSj5qim/Ocx wgfX1inTcipTNoqq+NKyKYGmnJZmSrfmL7zbiFKBx83J0VR2rVBmw1oPZC1f4xRfeNQ/zEgHlx87h d0B3dPcxpgwcMxEvH5KlBdJ0JNckK92hUfKh2ilJMOboTdFDjyQQqPmzGpyOtDE3SzSShTz/B2dn+ 1DI72PaS6N7M3uywVuhVWu3mxv4XO3/9PII7AmDFHYMIp9tfY8xvbEw2R25nzhWeFxYWBGWetFtSO 4cxkrOWBBevuoGiFb6SpO+qgdj8/1kPEFgPCGdfJpHQzqFxWmz8AB4niEIvgUc4hdBuwxda5HTI4x dwYo5E+nA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHb4F-006zbD-Ib; Wed, 03 Mar 2021 23:38:15 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUyN-005jTI-KO for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L6Xn+u33CPNxO4HFinhCXFka/RB/0sOFe6x8iRrvQEw=; b=SQpPwcaVVETatU0xUURJhxqQ0uin7H9sg6znajNMR0f4ueOoPgX3IRJUmDW4e13vKTfo03 RFHJ2bW36gcDX3peFMOs0ygjkk4o2fS9PhN/Ofuv7MmtFmyoeXNeQp0F0oBEqK7xCmmu/F dmKGxmvlD+70kPDjXZpcpaY9TCy+Bcc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-496-wMxd_JLVPgGOEOmWs_zAgw-1; Wed, 03 Mar 2021 12:06:07 -0500 X-MC-Unique: wMxd_JLVPgGOEOmWs_zAgw-1 Received: by mail-wm1-f72.google.com with SMTP id y9so2066226wma.4 for ; Wed, 03 Mar 2021 09:06:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L6Xn+u33CPNxO4HFinhCXFka/RB/0sOFe6x8iRrvQEw=; b=jJjqzGFgy4PdoVFf9ys9mNaIim+Ud9nUNFHX6XypbqEutSHtUe8NMnYXdVvZu/D+8x ZqrJSH+j2sul3erwdHlc9+9oc2uL8ardat6acicFWq4hbjH/fv4tpTAdHe3lIWB5Q9z4 FFTPSqnkL9NX01+nSnrv3Y2c7HMDrwWHfpK6rk6PfuuL60tz5tbwGQ75K0EkSrOEQ3/c CaZIF2uGZJLuOIdZgSOD5KOa02rr0y30N5hFjx/s+j4wot/C4WNBG3I0yzqvYPAwYgBa GNKiXgCs7amLO9+uT27kKp0c6elcc4pg8onpvh/35ZMgKSqxD992ifY84WA15e8V/0nh Af+A== X-Gm-Message-State: AOAM530rKVMFsHHrOq0a2oRWkn898IT/0qYMovh07BX9e/TrIE2K+UFq 2SyLC3AgsBSnJDzCe1NcnXfbZh/amQVs1QNJgCzPjgqzFreqxDnQD6e1WnYRHfgYUfemTPVpL5L j2LE+VzDWZYwBFeB2abQe/v+sNfbjWp9KduA= X-Received: by 2002:adf:ebc9:: with SMTP id v9mr28671226wrn.387.1614791166005; Wed, 03 Mar 2021 09:06:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpZBXzvFoGUuSttyR1nFY9YigBcVkN3UpeHTBedmmsMa9WDXR2BdsJ4M3u3ibeINwYxZYl7Q== X-Received: by 2002:adf:ebc9:: with SMTP id v9mr28671202wrn.387.1614791165608; Wed, 03 Mar 2021 09:06:05 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:06:05 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 6/8] arm64: insn: Add barrier encodings Date: Wed, 3 Mar 2021 18:05:34 +0100 Message-Id: <20210303170536.1838032-7-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Create necessary functions to encode/decode aarch64 barrier instructions. DSB needs special case handling as it has multiple encodings. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/insn.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index b55b629c5eab..185f52ef0228 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -370,6 +370,14 @@ __AARCH64_INSN_FUNCS(eret_auth, 0xFFFFFBFF, 0xD69F0BFF) __AARCH64_INSN_FUNCS(mrs, 0xFFF00000, 0xD5300000) __AARCH64_INSN_FUNCS(msr_imm, 0xFFF8F01F, 0xD500401F) __AARCH64_INSN_FUNCS(msr_reg, 0xFFF00000, 0xD5100000) +__AARCH64_INSN_FUNCS(dmb, 0xFFFFF0FF, 0xD50330BF) +__AARCH64_INSN_FUNCS(dsb_base, 0xFFFFF0FF, 0xD503309F) +__AARCH64_INSN_FUNCS(dsb_nxs, 0xFFFFF3FF, 0xD503323F) +__AARCH64_INSN_FUNCS(isb, 0xFFFFF0FF, 0xD50330DF) +__AARCH64_INSN_FUNCS(sb, 0xFFFFFFFF, 0xD50330FF) +__AARCH64_INSN_FUNCS(clrex, 0xFFFFF0FF, 0xD503305F) +__AARCH64_INSN_FUNCS(ssbb, 0xFFFFFFFF, 0xD503309F) +__AARCH64_INSN_FUNCS(pssbb, 0xFFFFFFFF, 0xD503349F) #undef __AARCH64_INSN_FUNCS @@ -381,6 +389,20 @@ static inline bool aarch64_insn_is_adr_adrp(u32 insn) return aarch64_insn_is_adr(insn) || aarch64_insn_is_adrp(insn); } +static inline bool aarch64_insn_is_dsb(u32 insn) +{ + return (aarch64_insn_is_dsb_base(insn) && (insn & 0xb00)) || + aarch64_insn_is_dsb_nxs(insn); +} + +static inline bool aarch64_insn_is_barrier(u32 insn) +{ + return aarch64_insn_is_dmb(insn) || aarch64_insn_is_dsb(insn) || + aarch64_insn_is_isb(insn) || aarch64_insn_is_sb(insn) || + aarch64_insn_is_clrex(insn) || aarch64_insn_is_ssbb(insn) || + aarch64_insn_is_pssbb(insn); +} + enum aarch64_insn_encoding_class aarch64_get_insn_class(u32 insn); bool aarch64_insn_uses_literal(u32 insn); bool aarch64_insn_is_branch(u32 insn); From patchwork Wed Mar 3 17:05:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476EDC433DB for ; Wed, 3 Mar 2021 23:42:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9C5760C41 for ; Wed, 3 Mar 2021 23:42:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9C5760C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jlT7WYStVTDjSltq9d+s0GNOMx0BGTm1qG7150+9L9w=; b=fVOh5Xh+QMhtbSeQG9QQKmxeL DasxormD86azEPa1cpAA8vG4RMYb5qNRuWp68lYl5952r/5Jw9w1m8k8FPyrAPW0awr00ZEJriHiP BXfEeh+sPIWVT4ZXp445ne05STE3vbo7MyeVQ4X4bq8E8fJKgQQhpA0zgoh/p0FQiCljzabulLXRR el+T+QuLpxLxH6J1HR1VyPew+OSLB0NeBIV5IOpgFlAvcl415YHEZK+ZLVP1jTzGJZ5+sDDPH4svZ Mj/kbs5Yo/AwxC8WIrS76lZiEHenqyt2oeQU4bBK03Vv9YAlXpvflDf+GxxmWKXESp41K1RaHfSM6 Fz1GBoecw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHb2N-006zCT-Sb; Wed, 03 Mar 2021 23:36:29 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUyM-005jSr-Kj for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=64/r5WkavI4S3gZoMp8frzL6ATRD8fIGn6DON6cVWDE=; b=U3mQ9ualQ7bDDdgQ2OjMR+Sly3BZdX1PIjFQ9BCFEpW/Nvreg6KtdDjYbvuxOnoDrT62xJ qjTb5S49jvz57UW7Q3IvjtMS3WKf72QxsjgKdX9/h0yAoSxtggHNYaJrrWK8rUiTOSUMqK Vk6oUq802WK+Z3ygLRazshDQRHAKMXM= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-EMg2HvuPOd6OOJHL7I3YfQ-1; Wed, 03 Mar 2021 12:06:10 -0500 X-MC-Unique: EMg2HvuPOd6OOJHL7I3YfQ-1 Received: by mail-wr1-f72.google.com with SMTP id h5so4602345wrr.17 for ; Wed, 03 Mar 2021 09:06:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=64/r5WkavI4S3gZoMp8frzL6ATRD8fIGn6DON6cVWDE=; b=tpDNgpXgEGNAWj8SNMy16jxSyPlEimCWKx617w9uVSJmUkEpWAK7Yyv8PbYF25yV/a SKBLRoZgRCciJLXivkhvJC8V3O/qElAhDTNxLDCjR8ueXJlTvau7xiUCiegyNDkryZKw PmXZ3xtpegtLg3yUTcDgVwZncRGKHEs+YR9KDhTVOvxzMeJAp5j/5wlnCbh2JB8kw9vZ wcFKxKKdadaxCxCMnSVVB+YqKukVjNfFmtHMxIfwPqYuZemZ2vc2LFcMzf4iicip6NTk xz+yzZwb+7EEw1Fi3MYC/VT3kdkCHf/7w4tbvy621injwwAPEuf/HZrOsBdwJPSkc7LQ vfJA== X-Gm-Message-State: AOAM530D56i5C3lflhnCRCI7QQ1k06tO22yngEE5wDSnxFkXJdhj7ue6 zgHwOTzJnKegIvo4uNDpeYDCIuoVEYxHcHNuuytO0HMsI3LlU6PUqeZ8BQcuNAALbt3xeftcbIB /CM0aWUiVLSkMTjKs144sweeakLacF7g9WYY= X-Received: by 2002:a5d:56c9:: with SMTP id m9mr27514924wrw.422.1614791167644; Wed, 03 Mar 2021 09:06:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXgg4LC86syFIZcm3E1I9s1XBSGKdgt+1bHuhqJPSgqyu1UN0Tf170oV70c/ULAuYT4m1/Rw== X-Received: by 2002:a5d:56c9:: with SMTP id m9mr27514907wrw.422.1614791167413; Wed, 03 Mar 2021 09:06:07 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:06:07 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 7/8] arm64: insn: Add some opcodes to instruction decoder Date: Wed, 3 Mar 2021 18:05:35 +0100 Message-Id: <20210303170536.1838032-8-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add decoding capability for some instructions that objtool will need to decode. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/insn.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index 185f52ef0228..388aa22eacb1 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -296,6 +296,12 @@ __AARCH64_INSN_FUNCS(adr, 0x9F000000, 0x10000000) __AARCH64_INSN_FUNCS(adrp, 0x9F000000, 0x90000000) __AARCH64_INSN_FUNCS(prfm, 0x3FC00000, 0x39800000) __AARCH64_INSN_FUNCS(prfm_lit, 0xFF000000, 0xD8000000) +__AARCH64_INSN_FUNCS(store_imm, 0x3FC00000, 0x39000000) +__AARCH64_INSN_FUNCS(load_imm, 0x3FC00000, 0x39400000) +__AARCH64_INSN_FUNCS(store_pre, 0x3FE00C00, 0x38000C00) +__AARCH64_INSN_FUNCS(load_pre, 0x3FE00C00, 0x38400C00) +__AARCH64_INSN_FUNCS(store_post, 0x3FE00C00, 0x38000400) +__AARCH64_INSN_FUNCS(load_post, 0x3FE00C00, 0x38400400) __AARCH64_INSN_FUNCS(str_reg, 0x3FE0EC00, 0x38206800) __AARCH64_INSN_FUNCS(ldadd, 0x3F20FC00, 0x38200000) __AARCH64_INSN_FUNCS(ldr_reg, 0x3FE0EC00, 0x38606800) @@ -304,6 +310,8 @@ __AARCH64_INSN_FUNCS(ldrsw_lit, 0xFF000000, 0x98000000) __AARCH64_INSN_FUNCS(exclusive, 0x3F800000, 0x08000000) __AARCH64_INSN_FUNCS(load_ex, 0x3F400000, 0x08400000) __AARCH64_INSN_FUNCS(store_ex, 0x3F400000, 0x08000000) +__AARCH64_INSN_FUNCS(stp, 0x7FC00000, 0x29000000) +__AARCH64_INSN_FUNCS(ldp, 0x7FC00000, 0x29400000) __AARCH64_INSN_FUNCS(stp_post, 0x7FC00000, 0x28800000) __AARCH64_INSN_FUNCS(ldp_post, 0x7FC00000, 0x28C00000) __AARCH64_INSN_FUNCS(stp_pre, 0x7FC00000, 0x29800000) @@ -336,6 +344,7 @@ __AARCH64_INSN_FUNCS(rev64, 0x7FFFFC00, 0x5AC00C00) __AARCH64_INSN_FUNCS(and, 0x7F200000, 0x0A000000) __AARCH64_INSN_FUNCS(bic, 0x7F200000, 0x0A200000) __AARCH64_INSN_FUNCS(orr, 0x7F200000, 0x2A000000) +__AARCH64_INSN_FUNCS(mov_reg, 0x7FE0FFE0, 0x2A0003E0) __AARCH64_INSN_FUNCS(orn, 0x7F200000, 0x2A200000) __AARCH64_INSN_FUNCS(eor, 0x7F200000, 0x4A000000) __AARCH64_INSN_FUNCS(eon, 0x7F200000, 0x4A200000) From patchwork Wed Mar 3 17:05:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12114569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3569BC433E0 for ; Wed, 3 Mar 2021 23:42:51 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99A6660C41 for ; Wed, 3 Mar 2021 23:42:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99A6660C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XALZ0mI/+8GG925sfCNidEWozEXdi1cHV1AHGUXj8kE=; b=InDfu+8mi83KsUMbcnVUrMBVG F9cTrIgsUkS7vegfxwedJ6zND0UavcCxxykpYDsH+hHqEel2keOiLptHEjLcGI1Y8mhSG2+OMtkMk DAYMpTEsaRUQz+cGU01tGUPJEhVD9qflYXuhzeCRw2aSwurWW2OJW3jn+UnqXqeYOFKKAQU6ipFpT acj5SnnPbX90fgrnJOLyWLJeJvrFhgNA9lZnyWumUJSd4Sx3spafd2zMLr+YpoOmkTtKfqUn6jd1X IQCVEtln0R6JrQ7NH1s8Oi652to3c2y51GhRK7AJXlhC8PdTmZdzxkbDAQ584z2R3+9d75b4KcY5g lLQaRdFdA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHb33-006zOc-KI; Wed, 03 Mar 2021 23:36:57 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHUyP-005jTe-7g for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:07:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614791263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ZOme96OqfHDGW4Rd2dxm5kzYLLlb1jU0OpF+Zj1BLY=; b=CUtKXTYNgxQu5v5El4AV6syP0Rj+5iYvkB5bLlfEGcDmLWjfklBBjOfY4fpdOG3+Q668ie tgg9S2/G8cEfZJvtUtvt3mejkxPsLxXGiWZP9kRY2uGfMiaMwJ8c/OO/Df89209iXXy+1u wtJ7DoEiRBPBHpLJ8ddunv2qR0DhsVs= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-eJUsanlwMgOaBhF-GAP_dg-1; Wed, 03 Mar 2021 12:06:11 -0500 X-MC-Unique: eJUsanlwMgOaBhF-GAP_dg-1 Received: by mail-wr1-f70.google.com with SMTP id v1so2489634wru.7 for ; Wed, 03 Mar 2021 09:06:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ZOme96OqfHDGW4Rd2dxm5kzYLLlb1jU0OpF+Zj1BLY=; b=tYrUUp6FSlIrLdse1fPnkK3ZHgRvq8lFnJmG1VquhBIu89ITTfY7N4lwmLDgrI6uB1 tl6UMatA+R/3uzM175ZFKLVwN/5TCnpjzSjCu9KtX5QVq+jEAQbcfF7qc24xAlkCRDki My07tNUAOWZpK6jTVezaB5Zm7C2q+kvn7NVdIp1uNuhUqqWtEQfGRrZNOgzo+ajux867 uDbOMUqTSpCwai0B5SLhUB2tb5nT1DbvcmKNMT4GAC4QaXS1rgCgqXFfxbQ7O/cmXRL1 HKBXPpA/52UySNLeHb3Ssz970bajJWU2pjKyv/eTCM7faDuSEVE++1ZS1vv/5/h8Ic1K LyYQ== X-Gm-Message-State: AOAM533E0Btp1qlH+82zfxyANUuRMaeH6OmHZ0jJ2tl8CMZjHq6+vPG9 P7LRgaQ/Wasmu/VomSx851vHaLRyRziQ0yyFfxnchRbjoAE5g71r7fQ1HAoIcD0rHkUSuJvwwCM ZswRq+/7cSLflXr0SsihKQNyXwHoROm2IzaU= X-Received: by 2002:a5d:4d09:: with SMTP id z9mr27544902wrt.426.1614791169958; Wed, 03 Mar 2021 09:06:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxskyOrQHsycuKN7L4vDRKVmFDW3FGA9b5LTWtx2cz/oHzRiG9JoZ1yHI1kcOZ3L1fAYVISgw== X-Received: by 2002:a5d:4d09:: with SMTP id z9mr27544882wrt.426.1614791169682; Wed, 03 Mar 2021 09:06:09 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id d29sm32957827wra.51.2021.03.03.09.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:06:09 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, broonie@kernel.org, ycote@redhat.com, Julien Thierry Subject: [RFC PATCH v2 8/8] arm64: insn: Add load/store decoding helpers Date: Wed, 3 Mar 2021 18:05:36 +0100 Message-Id: <20210303170536.1838032-9-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303170536.1838032-1-jthierry@redhat.com> References: <20210303170536.1838032-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide some function to group different load/store instructions. Signed-off-by: Julien Thierry --- arch/arm64/include/asm/insn.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index 388aa22eacb1..71de52d1532f 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -412,6 +412,34 @@ static inline bool aarch64_insn_is_barrier(u32 insn) aarch64_insn_is_pssbb(insn); } +static inline bool aarch64_insn_is_store_single(u32 insn) +{ + return aarch64_insn_is_store_imm(insn) || + aarch64_insn_is_store_pre(insn) || + aarch64_insn_is_store_post(insn); +} + +static inline bool aarch64_insn_is_store_pair(u32 insn) +{ + return aarch64_insn_is_stp(insn) || + aarch64_insn_is_stp_pre(insn) || + aarch64_insn_is_stp_post(insn); +} + +static inline bool aarch64_insn_is_load_single(u32 insn) +{ + return aarch64_insn_is_load_imm(insn) || + aarch64_insn_is_load_pre(insn) || + aarch64_insn_is_load_post(insn); +} + +static inline bool aarch64_insn_is_load_pair(u32 insn) +{ + return aarch64_insn_is_ldp(insn) || + aarch64_insn_is_ldp_pre(insn) || + aarch64_insn_is_ldp_post(insn); +} + enum aarch64_insn_encoding_class aarch64_get_insn_class(u32 insn); bool aarch64_insn_uses_literal(u32 insn); bool aarch64_insn_is_branch(u32 insn);