Received: by 2002:a4f:b056:0:0:0:0:0 with SMTP id m22csp1391672ivi; Fri, 2 Oct 2020 09:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl0T0DNqyCIbz4NobTqHLy2tDdqN17kn/Nuo90EvhU0ys/NdOikr1T7+9/KVs03KYUrnQn X-Received: by 2002:a17:906:95cd:: with SMTP id n13mr2904175ejy.297.1601654589095; Fri, 02 Oct 2020 09:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601654589; cv=none; d=google.com; s=arc-20160816; b=tpX+q9LWkPanYiyjkBuBkCIJ0e95YOZ2QeXFSGlxIvLAOeck8h51RXT8mqLO6ga/00 F889QJnp8zgJrbboSaeJuONzHsEG15SxkzBwEwwerg4G/DjzprNxSR9UWh/UMb8MKmKI 8AY3mwhhvVlnhyMjj9P8fLe8jf8r43g56qHQpBHYDoc5exA5iLsUHeR/M1xP2A1/weRX uvTzYg8gnn54JADfmtUT13iOI0YyeThbtgqe7TqkbKdiGqyXQzy1Q7YjBLxhZZuFwS4L zWnvqAXYDm9bisoVrObMxeKvI0ha/y/mJkhdfw3H/+Im3z9HdPQx3Qh03CmcdeGJ7wDB hUcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1Jor+fjjZlrkYFKsnf/j6ujMU3fQARqQ9kGgIywfWC4=; b=kLFe8RWBzquoXv+yoFRho9I1/3KqrqFBImdhlMijPCu8e1EU/ViiFtIn+vWfUNwWRB d5lXYVCK9DVApJhT3L6dY9KjsWh8eYlHWdxebOmfZKv88MsfeVktHo/69iopJjWaFqOY rsH6x3/klWWXkVuF3Y2xK8pbcqGf5o1aXp6xRHtX6GbCt1ZMAaNsGCYqyE9Qjhoca7QX e2ErSomQ3Mh7pj/1j8oyssxxHpp6hEO1+si03nj55ENpf6N9K8tY091iyhNlBCflLlV8 VOju4ekMSLWAUivhXRL5MI1mq3qynA0sZP/UUsTrpuT0siMZoGw49UTvpIt+FLDj03VS /DqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ibySHBnY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si1546049ejh.697.2020.10.02.09.02.45; Fri, 02 Oct 2020 09:03:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ibySHBnY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387974AbgJBQB1 (ORCPT + 99 others); Fri, 2 Oct 2020 12:01:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58500 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbgJBQBZ (ORCPT ); Fri, 2 Oct 2020 12:01:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601654484; 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: in-reply-to:in-reply-to:references:references; bh=1Jor+fjjZlrkYFKsnf/j6ujMU3fQARqQ9kGgIywfWC4=; b=ibySHBnY9Qu3Qwz2LxjSS4A/USz2ju7TGV/jEzKJa87mvwolDUTjnoiMIzVD99Hn+TPIom h2llCy62IveFbzORsoQ4LDp6zl6tZVSlJPX4NUlhjmi7y60VOB1UU5L+1i9pq4JBcxxU5x 8Bn0dCaQ5urE11+LUikjqbFzhx0SDkE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-zisXQFNnM7ymFS_9xFuHoA-1; Fri, 02 Oct 2020 12:01:22 -0400 X-MC-Unique: zisXQFNnM7ymFS_9xFuHoA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 157ED1054F8E; Fri, 2 Oct 2020 16:01:21 +0000 (UTC) Received: from treble (ovpn-114-202.rdu2.redhat.com [10.10.114.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4275F73683; Fri, 2 Oct 2020 16:01:17 +0000 (UTC) Date: Fri, 2 Oct 2020 11:01:14 -0500 From: Josh Poimboeuf To: Vasily Gorbik Cc: Peter Zijlstra , Thomas Gleixner , Masami Hiramatsu , David Laight , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Miroslav Benes , Alexandre Chartre , Julien Thierry , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v3 4/4] objtool: fix x86 orc generation on big endian cross compiles Message-ID: <20201002160114.7yb7z7aeijhchpwl@treble> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 01, 2020 at 12:17:32AM +0200, Vasily Gorbik wrote: > +++ b/tools/objtool/arch/x86/special.c > @@ -9,7 +9,7 @@ > > void arch_handle_alternative(unsigned short feature, struct special_alt *alt) > { > - switch (feature) { > + switch (le16_to_cpu(feature)) { It might be cleaner for the endian conversion to be done when the 'feature' value is first read. feature = *(unsigned short *)(sec->data->d_buf + offset + entry->feature); > case X86_FEATURE_SMAP: > /* > * If UACCESS validation is enabled; force that alternative; > diff --git a/tools/objtool/check.c b/tools/objtool/check.c > index 2df9f769412e..f20a4be2fb22 100644 > --- a/tools/objtool/check.c > +++ b/tools/objtool/check.c > @@ -1370,7 +1370,7 @@ static int read_unwind_hints(struct objtool_file *file) > cfa = &insn->cfi.cfa; > > if (hint->type == UNWIND_HINT_TYPE_RET_OFFSET) { > - insn->ret_offset = hint->sp_offset; > + insn->ret_offset = le16_to_cpu(hint->sp_offset); Since this is common code, we might not always be able to assume the value is little endian. Could you make a more generic conversion macro which -- when the target ELF file's endianness doesn't match the host CPU's -- does a byte swap? For example: insn->ret_offset = bswap_if_needed(hint->sp_offset); The macro could detect the type size, and would also know the host/target endianness, and could swap accordingly. It could then be called for all such multi-byte reads. -- Josh