Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4473893imm; Mon, 11 Jun 2018 12:58:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIA6CrLYLPi0MyucXwUYBeM55qN0uhtK97/YEPpX8LzNs3BD4KYGgL54DYJBCUCrBc9hQOH X-Received: by 2002:a63:7211:: with SMTP id n17-v6mr500922pgc.94.1528747134565; Mon, 11 Jun 2018 12:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528747134; cv=none; d=google.com; s=arc-20160816; b=uY/vgkIu1J0M6Z8jaIz86hTd+t96Dh43ftArqJaY/JYHwEm2jG1H3NS4+Rz7InInsA nqCpf487gCSI7lK3u9gpiwRbf2Ukml7E4o5S0oF55yEY5FsumQzyjgr+uQMwNB5yUogT gB/GATryH3JGYhiyKOkkBhAi69s0+saiB4DRyuePJHj/lUR/n3/eBUNiA8wqRofFWBJj M8TjEQrjdNEweCG6wCrNmfT8oGMi02DpZk507yy+SsDe3l+wLBCZC7mCp7Z2jA+qZUbL oz+RH/3s62CaAIUKkXesIG7E2to3t313T9PnCk2RnE9VC3ol275ZylI3Sm08D9jS/qpT b9ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature :arc-authentication-results; bh=5f7yfRDyQ0fcqV7vIas5H4Rx+CaGEJSrNiYcpltsYXo=; b=NSelV+//dRMFjZUHRScBdHuyH45sgN2HZdp2npWG3EfPCqmxECV9BWumWAZGQJoKIn NOs4KykX34qoeFmEIwyGiJzl7iIstR4GKr6NUFO+kgPvDXZimoYnKZ0jHqtuaIB8TUvb 0ULTSARiQwZBDFoAHc4zK434gheZFvMrJprhDxd6nFKbwWGayKKSRepqIiBAiiCSZ95A OzT+3htF+nSqWRxpCxsmRuEQpo4PiO0FN9Lh7EErC2Ln7NbvjbGoX6kErJh4cUlHMNhp j4LUV0bfsiw5nRU1ZdUIfF9CY5Wpx/rP894ue5ASrKomZU18ovQlA44/VLKYZt/IvLvo Ovcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=C8CUy06F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13-v6si23891548pfh.92.2018.06.11.12.58.40; Mon, 11 Jun 2018 12:58:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=C8CUy06F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934562AbeFKTBl (ORCPT + 99 others); Mon, 11 Jun 2018 15:01:41 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33030 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933906AbeFKTBj (ORCPT ); Mon, 11 Jun 2018 15:01:39 -0400 Received: by mail-pl0-f66.google.com with SMTP id n10-v6so12849043plp.0 for ; Mon, 11 Jun 2018 12:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=5f7yfRDyQ0fcqV7vIas5H4Rx+CaGEJSrNiYcpltsYXo=; b=C8CUy06FPIdlXnnaY0cNl3EYlj44UFElJTSsuRbUKfmPO/zsd5NjE+pNZybruINnji Jd5+FA7EpYZCRxiu7dcmEJVsoDAnP7gnkCeasnVfzvWKmzIacQYGJabg8bSr/TvezKJ1 qcwo/h5tDw1gFPVq954RGYHcCX9Np4BWzH0cFJerJJzJlOexpIXrNGgrufqc7lc+4QA5 rceUzyK3Kpi+iSooqU36OqAytErnIqFqpxh0mUMgPGsBaotR/teAPb88rdHAhoXWndlB bbKRLkipaz4Yo+gR4W1gs8nAB8Pw4c/EO6BnYz69rTi5zHAEGqn25sWrn7nlkuuSMNT1 TUBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=5f7yfRDyQ0fcqV7vIas5H4Rx+CaGEJSrNiYcpltsYXo=; b=N/wTFiSVV2BS8FZJGQXDX0I11GWUxuB4AmqgNT96k/lP8gbgNI9MDudMPqR01Ri++x eezjzYYWh8x7Jc+KWynDnCj4cOHF0awvLT6SFtTTd1vNCw4CLbIOf3dLzSTw5hKA15mT A/RXv+1TTvjKRoIP3uUgyg79cw5P4RUsYmmcvE+S1pEP+PUiXqnR1133qrIc+lSiS7ja DjEraOttDS+C8V8ctCBVB3ATjYdAPdHiT1F+KdBnAy1SjFwuP+e1lUQU4EYPtp9qp1MC cpyyCpHgomAhS3LeA1xTZ87gAP2PfciyEXxRqMmVzuaEpA8H5CxEeDWHRNJQkQH6gSbi TgEA== X-Gm-Message-State: APt69E2MSPqccnjEJW2eoZZQW0F/4QWSax+4mWP5Ne8cW0wm7tl2hX77 VugMT82czBk5jJPAfRJZ1ze77A== X-Received: by 2002:a17:902:5602:: with SMTP id h2-v6mr417121pli.314.1528743698269; Mon, 11 Jun 2018 12:01:38 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id y15-v6sm3994037pfm.136.2018.06.11.12.01.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 12:01:37 -0700 (PDT) Date: Mon, 11 Jun 2018 12:01:37 -0700 (PDT) X-Google-Original-Date: Mon, 11 Jun 2018 12:01:29 PDT (-0700) Subject: Re: [PATCH 3/3] riscv: fix __user annotation for __copy_user() In-Reply-To: <20180609214211.u42vfrddl75ow7bb@ltop.local> CC: atish.patra@wdc.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, albert@sifive.com From: Palmer Dabbelt To: luc.vanoostenryck@gmail.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 09 Jun 2018 14:42:12 PDT (-0700), luc.vanoostenryck@gmail.com wrote: > On Sat, Jun 09, 2018 at 01:00:08PM -0700, Palmer Dabbelt wrote: >> On Fri, 08 Jun 2018 17:13:12 PDT (-0700), luc.vanoostenryck@gmail.com wrote: >> > I tried it and ... the preprocessed asm is as expected: >> > .globl __asm_copy_to_user ; .balign 4 ; __asm_copy_to_user: >> > .globl __asm_copy_from_user ; .balign 4 ; __asm_copy_from_user: >> > >> > >> > li t6, 0x00040000 >> > csrs sstatus, t6 >> > ... >> > >> > But the nm -S returns different sizes for them: >> > 0000000000000004 000000000000006c T __asm_copy_from_user >> > 0000000000000002 000000000000006e T __asm_copy_to_user >> > >> > and the object code is: >> > 0000000000000000 <__asm_copy_to_user-0x2>: >> > 0: 0001 nop >> > >> > 0000000000000002 <__asm_copy_to_user>: >> > 2: 0001 nop >> > >> > 0000000000000004 <__asm_copy_from_user>: >> > 4: 00040fb7 lui t6,0x40 >> > 8: 100fa073 csrs sstatus,t6 >> > ... >> > >> > Why these unnneded nops? >> > Is this a known problem of my toolchain (I use a plain gcc 7.3 + >> > binutils 2.29, both configured as riscv64-none-elf)? >> > >> > If I remove the two ENTRY() and use instead: >> > .globl __asm_copy_to_user ; __asm_copy_to_user: >> > .globl __asm_copy_from_user ; __asm_copy_from_user: >> > (IOW, I drop the .balign) then I get the expected result. >> > But well, this seems unrelated to the double ENTRY. >> > >> > I can't test it more for now because I've some link errors (which, >> > I understand are probably solved in the riscv tree of binutils). >> > >> > I'll send you the patch anyway since, as far as I understand the changes >> > specific to this copy_to/from_user is OK. >> >> I think it's probably a bug in binutils-2.29 that should be fixed by >> 2.30 -- IIRC we had some bugs that looked like this and they got >> fixed, though it might be just in master (so 2.31). > > I've tried binutils-2.30 and riscv-binutils-gdb, both still have > the problem and master binutils-gdb doesn't compile for me. > OTOH, everything is fine if I disabled CONFIG_RISCV_ISA_C. OK, I'll try and figure out what's going on. We've had a handful of headaches trying to get things like '.align 2; .align 2' to actually produce no NOPs for the second alignment directive, which is surprisingly complicated due to the aggressive linker relaxation we do. >> Either way it looks innocuous WRT the patch. > > Indeed. > With this, the RISC-V arch should be sparse clean. > I'll recheck after -rc1. This will be part of the PR that I tag today, so I anticipate it'll be in. Thanks!