From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B031E3D6491 for ; Thu, 2 Apr 2026 12:48:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775134100; cv=none; b=TZUvv38hvxf9+bt/+ADNrxAevoctS+tuRAYGOHLZf670FUzha00wk3HP8sCci1psPQdNibRM182OyjbUzOuU8XWBqz0g5zVVqwh2SBXryQYkX+3FC7clUXrnnIEZgf6bM4wtzLpTRb7Q1g/Jl2BbsoRqg04WfAlOP8uJaqqN7xQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775134100; c=relaxed/simple; bh=yXGorwMYExCRdSLQz5l7S1HftX5UUFi7ZP+le/mn5h4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Dfl2wMG3DzRXq+x9rjFI+3m5W5TUAWD6WjNK6+uYe/j2EswtAjHjgNF9MrZ1KjYEjzgQq8J92FHzExylAFm9eZLvpm49HfNqwtljNs6KeaIRtku4xzpoT/sKROX8Ef2MwNWzIjqpkLYAx9cKQ7fSSYMxs4fx5l5hnZ5GBzw3ouc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dF2vjZXS; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dF2vjZXS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775134092; 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=4sfRm4YAsS0Hky8kj9MVqhUO/lsxhcl+40xreKHOZBs=; b=dF2vjZXS6I/gr+KJi7BNik2suDbLiSmU0uxRcoUyRbsaZ8ibEdcri62gmWwgrrcmTY14PG g8QbHJXKMJd1q3PGnhRysPxI416MCl7L5W5dGzlmtYt5KgJgfKXAWKcvcu17WoW29KQFbu yF9WM9UYrfZDMmob6mkLXbUAflD7nAs= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-330-ICPzhmFDPjqp0IYuMa1JUA-1; Thu, 02 Apr 2026 08:48:09 -0400 X-MC-Unique: ICPzhmFDPjqp0IYuMa1JUA-1 X-Mimecast-MFC-AGG-ID: ICPzhmFDPjqp0IYuMa1JUA_1775134088 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 30B241800372; Thu, 2 Apr 2026 12:48:07 +0000 (UTC) Received: from fedora (unknown [10.44.36.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id DAF6219373D8; Thu, 2 Apr 2026 12:48:03 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 2 Apr 2026 14:48:06 +0200 (CEST) Date: Thu, 2 Apr 2026 14:48:02 +0200 From: Oleg Nesterov To: Uros Bizjak Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: Re: [PATCH] x86/ptrace: Use savesegment() in get_segment_reg() instead of inline asm Message-ID: References: <20260402062248.459921-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260402062248.459921-1-ubizjak@gmail.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 04/02, Uros Bizjak wrote: > > @@ -251,32 +251,31 @@ static u16 get_segment_reg(struct task_struct *task, unsigned long offset) > /* > * Returning the value truncates it to 16 bits. > */ > - unsigned int seg; > + unsigned int retval; LGTM, but perhaps it would be better to use "u16 retval" ? and remove the comment. Oleg. > > switch (offset) { > case offsetof(struct user_regs_struct, fs): > if (task == current) { > - /* Older gas can't assemble movq %?s,%r?? */ > - asm("movl %%fs,%0" : "=r" (seg)); > - return seg; > + savesegment(fs, retval); > + return retval; > } > return task->thread.fsindex; > case offsetof(struct user_regs_struct, gs): > if (task == current) { > - asm("movl %%gs,%0" : "=r" (seg)); > - return seg; > + savesegment(gs, retval); > + return retval; > } > return task->thread.gsindex; > case offsetof(struct user_regs_struct, ds): > if (task == current) { > - asm("movl %%ds,%0" : "=r" (seg)); > - return seg; > + savesegment(ds, retval); > + return retval; > } > return task->thread.ds; > case offsetof(struct user_regs_struct, es): > if (task == current) { > - asm("movl %%es,%0" : "=r" (seg)); > - return seg; > + savesegment(es, retval); > + return retval; > } > return task->thread.es; > > -- > 2.53.0 >