From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754071AbbEMG6M (ORCPT ); Wed, 13 May 2015 02:58:12 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:35608 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbbEMG6K (ORCPT ); Wed, 13 May 2015 02:58:10 -0400 Message-ID: <5552F5FB.40005@redhat.com> Date: Wed, 13 May 2015 08:58:03 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Bandan Das CC: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, rkrcmar@redhat.com, guangrong.xiao@linux.intel.com, Yang Zhang , wanpeng.li@linux.intel.com Subject: Re: [PATCH 09/13] KVM: x86: save/load state on SMM switch References: <1430393772-27208-1-git-send-email-pbonzini@redhat.com> <1430393772-27208-10-git-send-email-pbonzini@redhat.com> <5549EF71.4080207@redhat.com> <554A6DC2.3010903@redhat.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/05/2015 01:56, Bandan Das wrote: > I think it's ok just to replace the offset number with a name. > If you are concerned about readability, we could probably wrap the > "for loops" in the math calculations with a more serious sounding macro > eg. "#define foreach_smm_offset(val, start_offset, jump, count)" :) That doesn't help. The problem is that the for loops assume that you know that the offsets are at a constant distance, plus the distance. This is already not trivial for the registers (is RAX at the highest or lowest offset); but it could even be worse than hardcoded offsets for selectors and descriptor caches. Paolo