From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90F433CE49F for ; Wed, 11 Mar 2026 10:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773224843; cv=none; b=luk6E7CqhRhnWIzGnnMiKwvU8gok/Zsqyr2H3EFNEucSTEkmzHtuCLYkcBE0jwuTD+TrkEGxwnHlE1l6zXEE9j+wm938vpMYNNMscr08VVhmX6B6kDFa7Y6nlky2fSC4CAn4TTNZu52tWEot+sImx2z3Q1As5P6f0sVwDbDhUwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773224843; c=relaxed/simple; bh=QOqdIysNMfx7osxoI2iP931xqvQTDt+cmUbB7PTG7ig=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JEPIRfF5LwXQ+Vqzf7O0aajLzLqob5YAQ/1iy3ZfQ01BoMw5qlXkXbtP3b/UO4tbbI6hkSqW0zHC0HqeiyzHveoZEoX+kierbZCizWINcvfIHS4MAS4DePontacdXbh98cb0GQAlkvQnYFGETnWdASSAk1uXJhdCFrSFZBlsSlk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a4/zNlN3; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a4/zNlN3" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4853aec185aso29374115e9.1 for ; Wed, 11 Mar 2026 03:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773224841; x=1773829641; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KvIJT6o/htTBgHQbPACbqowNMagVBntVqvO+Ajv0GV0=; b=a4/zNlN3RWBsV4w+3hITupFAmFwSGQfb3QtAbNMh/XVWh5VbALXFoXwmNS5sAhVJpQ hKD9mGTq6bAqpQZfwrempqQLxdu7WDUqDUU9DbmK1E/7HrNLVLOjxshRw6qE+vzKsxv/ 6remVJiQcOjXl1Iozkrs75T/mxFG1l6xAVGOFKMLI/mXVbNtnN9/rC1MVeopSFPxN8we Pm4EMw3135b1l/ov7AQ9C8l8gbtRwYwujiflFt6iFEpWclvKiutE19vAYJWEV5Np4Nep NfLaHJFSxLyyKFS5hU5sFq8++V6+YT6Fp93NmUuEqrETMp26oi/e9c9FGG0UFrVCC1Bv DD8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773224841; x=1773829641; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KvIJT6o/htTBgHQbPACbqowNMagVBntVqvO+Ajv0GV0=; b=V3AcU5fMlMA+a2XbPxJL5SJhPlRZcXk/UUiOvhFZJfQBeraUb/wzAuPVqMlhjaEAJT he9XRwrLtEREm5vTu77y4xVviHpMIdX49PeH+4+5z0gDeJUKJhtg/H4TMp4QNIPYyDXB RxqNAbPrpWBLVO6vk3PkdIAS7naFMP60R6PcupwIu75rzYm5mAQ/6o9mzCZCQjASeRu2 EDxisi/vfhUGTa/5ZuzxXPdY9Mg+hKh8GccDRvVBjmkJuJWq2VjT6FcX4FeqkMshcXm2 GFWmPc3Zs9i/7+aTMZRmtxK6uctudTciJKXG7SmOplf08V9gpUR0NgSOk34lBLuLqLXO TGzA== X-Forwarded-Encrypted: i=1; AJvYcCUzTlvDi029tEBarmN6x5GgPn8NWZ9PRbx5tUJdT4j8pObk6SiNEFb+4svtNd1taba7npjOAmZhj1l9dCE=@vger.kernel.org X-Gm-Message-State: AOJu0YxeT8LJ3NvzceMH5B1lzGmeuJQQgNj/F6weqv2IMhiTKAnkSfwi sVL6460pxkLcxXRcKB36hFCkCPrgR1yzulab52T//1cEroHFQMec8PVW X-Gm-Gg: ATEYQzytfFaCIXHNzdTBTC7cu5IYx8YhY3ZAqox6/Mt5wyLxsTx98zytRzjUnE6nB87 EMSjBdGHNxnLKklABA8/TKD+Lqityy8V7/KSyR4n26E67mK+52uFUyHZAxuozD1V8l7kyM47+kg KHC/lUsNJBPlwNa3IJz8i5+WgeGtXe8gMyI7vm0Zn3py62NFIBCu8A0o4wZb03xVHmC319RpBud iuB53pzejdDCEjubSxQzZjnIvqGuvs+Ocxjr2SBWqw76yohQ/mlIZPSoU0OMXDnUZl5+WwdyHpr Ujtg+PD3AiysEp4qwiBwdGsaYyAcgE3jrWin67Ns2+IrA9ySFd8Rx7mPLfMX+nV5645NFDBd9bB 4CyZrDVCmzx1jTVyGe/JFIx2EHFCGHlNFwsw/mmXakMHGhkhjnWHsZTjKE0KyKhDa23zYO3ha4Q SgOQF2MfJl3pVs43PHJQU/RDKnm/nMGp9kKlW4OeluBwHVFnASs0Ci3pmPaYx1Kwe8RkiQhmuXM FtT0LoKV7oneStCInJrNk4FMYAhE7Mk0fo0urOoMK6XqcuiGgezaQw= X-Received: by 2002:a05:600c:3493:b0:485:41c4:e2e5 with SMTP id 5b1f17b1804b1-4854b126f35mr31133855e9.27.1773224840758; Wed, 11 Mar 2026 03:27:20 -0700 (PDT) Received: from fedora ([193.77.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4854b5f6b95sm44534915e9.6.2026.03.11.03.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 03:27:19 -0700 (PDT) From: Uros Bizjak To: linux-hyperv@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH -hyperv 1/3] x86/hyperv: Save segment registers directly to memory in hv_hvcrash_ctxt_save() Date: Wed, 11 Mar 2026 11:25:58 +0100 Message-ID: <20260311102658.215693-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hv_hvcrash_ctxt_save() in arch/x86/hyperv/hv_crash.c currently saves segment registers via a general-purpose register (%eax). Update the code to save segment registers (cs, ss, ds, es, fs, gs) directly to the crash context memory using movw. This avoids unnecessary use of a general-purpose register, making the code simpler and more efficient. The size of the corresponding object file improves as follows: text data bss dec hex filename 4167 176 200 4543 11bf hv_crash-old.o 4151 176 200 4527 11af hv_crash-new.o No functional change occurs to the saved context contents; this is purely a code-quality improvement. Signed-off-by: Uros Bizjak Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Wei Liu Cc: Dexuan Cui Cc: Long Li Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" --- arch/x86/hyperv/hv_crash.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/hyperv/hv_crash.c b/arch/x86/hyperv/hv_crash.c index fdb277bf73d8..2c7ea7e70854 100644 --- a/arch/x86/hyperv/hv_crash.c +++ b/arch/x86/hyperv/hv_crash.c @@ -207,12 +207,12 @@ static void hv_hvcrash_ctxt_save(void) asm volatile("movq %%cr2, %0" : "=a"(ctxt->cr2)); asm volatile("movq %%cr8, %0" : "=a"(ctxt->cr8)); - asm volatile("movl %%cs, %%eax" : "=a"(ctxt->cs)); - asm volatile("movl %%ss, %%eax" : "=a"(ctxt->ss)); - asm volatile("movl %%ds, %%eax" : "=a"(ctxt->ds)); - asm volatile("movl %%es, %%eax" : "=a"(ctxt->es)); - asm volatile("movl %%fs, %%eax" : "=a"(ctxt->fs)); - asm volatile("movl %%gs, %%eax" : "=a"(ctxt->gs)); + asm volatile("movw %%cs, %0" : "=m"(ctxt->cs)); + asm volatile("movw %%ss, %0" : "=m"(ctxt->ss)); + asm volatile("movw %%ds, %0" : "=m"(ctxt->ds)); + asm volatile("movw %%es, %0" : "=m"(ctxt->es)); + asm volatile("movw %%fs, %0" : "=m"(ctxt->fs)); + asm volatile("movw %%gs, %0" : "=m"(ctxt->gs)); native_store_gdt(&ctxt->gdtr); store_idt(&ctxt->idtr); -- 2.53.0