Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5635909ybe; Tue, 17 Sep 2019 11:04:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx0PAhSeKduhAk6dS9mzc+/Oa3GCkOoGo6QXrcK7yWWDiUb7MACLInR/yQS8FLdVTJzk2p X-Received: by 2002:a17:906:1153:: with SMTP id i19mr5946447eja.160.1568743441693; Tue, 17 Sep 2019 11:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568743441; cv=none; d=google.com; s=arc-20160816; b=0gB3k/arkbU9PIy4r/q3Bn8qd6Jnkm57dthKrMByVhEmh7vGoAe810aL8lqLQalm/X 6KxeIXpetGlQvBhNU63PG6lsjSzUevK29hRlHwLG99j8mkoxacRE81pNdBlawdu11/Nu 3QPpOz3gPLFfJtGiErCToNY0R8g9P6jurxUDfI7niQmdlPXybA4rd1E90guO/y+zRiUY udoCslQX/8Nq4CaoOYunn4CyPFYc3TCTITgk32ILM08tFa5r3IM1R2Zmut6p55rpQBdc lYUFpZdK44E1NCKj8xRKSCXQ7/NRksRjdweI+lBhxFnNoci769upkaTI5lz3juJwOdga 6iVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0bAgzlZNstEjBWMqeqMDyneCcpC34gIV353IuRCgPkA=; b=xg0Vv+7wZLMT+5xdqfOEnRx39QXWP27mG4c86YSfNFAQi88W2DdGsR6zoXItA76n4e akSCwjKFyHMBTUKinBvZvORFCdFrEnWJ1PanOYnjL6R5nGgvgRpU7+Q/XSgrFNV9WfDc 4I67mrm5QFUwIeCOY65gV6WTCrFDlNbm5RQ1lpJ+A61umotKVMXyh07bdTL0ojX7DTrP vX5cNeOFSKUUMpVgy9lkw5YTA5KFbi25L3dYdgO2UQ5VTJlJy+r4jTF1/5aIpiGwnGN2 0W4t26dPYjkF8GvhnHup9m6cYVrtLhuyk82VoRHPo+6BbrJ2TyXDgl3+2BpqhjMYQzi+ YW1w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si1873131edb.56.2019.09.17.11.03.37; Tue, 17 Sep 2019 11:04:01 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728479AbfIQOiA (ORCPT + 99 others); Tue, 17 Sep 2019 10:38:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26541 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbfIQOiA (ORCPT ); Tue, 17 Sep 2019 10:38:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F7CB8980EF; Tue, 17 Sep 2019 14:37:59 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.72]) by smtp.corp.redhat.com (Postfix) with SMTP id 4A7FF5DC18; Tue, 17 Sep 2019 14:37:54 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 17 Sep 2019 16:37:59 +0200 (CEST) Date: Tue, 17 Sep 2019 16:37:53 +0200 From: Oleg Nesterov To: Benjamin Herrenschmidt , Madhavan Srinivasan , Michael Ellerman , Paul Mackerras Cc: Jan Kratochvil , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH? v2] powerpc: Hard wire PT_SOFTE value to 1 in gpr_get() too Message-ID: <20190917143753.GA12300@redhat.com> References: <20190917121256.GA8659@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190917121256.GA8659@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Tue, 17 Sep 2019 14:37:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I don't have a ppc machine, this patch wasn't even compile tested, could you please review? The commit a8a4b03ab95f ("powerpc: Hard wire PT_SOFTE value to 1 in ptrace & signals") changed ptrace_get_reg(PT_SOFTE) to report 0x1, but PTRACE_GETREGS still copies pt_regs->softe as is. This is not consistent and this breaks http://sourceware.org/systemtap/wiki/utrace/tests/user-regs-peekpoke Reported-by: Jan Kratochvil Signed-off-by: Oleg Nesterov --- arch/powerpc/kernel/ptrace.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 8c92feb..291acfb 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -363,11 +363,36 @@ static int gpr_get(struct task_struct *target, const struct user_regset *regset, BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) != offsetof(struct pt_regs, msr) + sizeof(long)); +#ifdef CONFIG_PPC64 + if (!ret) + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &target->thread.regs->orig_gpr3, + offsetof(struct pt_regs, orig_gpr3), + offsetof(struct pt_regs, softe)); + + if (!ret) { + unsigned long softe = 0x1; + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &softe, + offsetof(struct pt_regs, softe), + offsetof(struct pt_regs, softe) + + sizeof(softe)); + } + + BUILD_BUG_ON(offsetof(struct pt_regs, trap) != + offsetof(struct pt_regs, softe) + sizeof(long)); + + if (!ret) + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &target->thread.regs->trap, + offsetof(struct pt_regs, trap), + sizeof(struct user_pt_regs)); +#else if (!ret) ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.regs->orig_gpr3, offsetof(struct pt_regs, orig_gpr3), sizeof(struct user_pt_regs)); +#endif if (!ret) ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, sizeof(struct user_pt_regs), -1); -- 2.5.0