From patchwork Mon Jan 14 17:33:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1973051 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7BFB8DF2E1 for ; Mon, 14 Jan 2013 17:33:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757340Ab3ANRdI (ORCPT ); Mon, 14 Jan 2013 12:33:08 -0500 Received: from mail-vc0-f182.google.com ([209.85.220.182]:55874 "EHLO mail-vc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756657Ab3ANRdG (ORCPT ); Mon, 14 Jan 2013 12:33:06 -0500 Received: by mail-vc0-f182.google.com with SMTP id fy27so3782893vcb.41 for ; Mon, 14 Jan 2013 09:33:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=q/h2UHrPOTDcoUy5RNR8yrjB3TzFwaZjrK1APGVu6nI=; b=gW8QVhpBy9NE/o8UoOLzM+vtYzZRmlJ27d0RTnVazvDXsYWmO9wlu9TeIeVyCC3Qr7 XoCD5j9vTdmy/WgatlosgNIPQTbUJ12DSBqzA9tBtVftpkvoXmCyORNLPznKXyNjezmW A239IW25JjosVplkeNHH700X7v4QxujSpqQ0DOs1bMT1q3H314hnVwwaTcs0jYDNdzuT 5+PKPuklprOGaXu7rxEYUTk8MWjcm7jwJAEd02VF2SNZi3iqobZ93bJLAJUY374kRiR0 zc/GvRjULxtk181bfI9fSPwARW1j8akJ6opxYILG+41e0fbEZEzBTlnElZ/xIYdkz67D zfQA== MIME-Version: 1.0 Received: by 10.220.241.80 with SMTP id ld16mr13071093vcb.5.1358184785895; Mon, 14 Jan 2013 09:33:05 -0800 (PST) Received: by 10.221.7.71 with HTTP; Mon, 14 Jan 2013 09:33:05 -0800 (PST) X-Originating-IP: [72.80.83.148] In-Reply-To: <20130114162415.GF23505@n2100.arm.linux.org.uk> References: <20130108183811.46302.58543.stgit@ubuntu> <20130108183855.46302.40539.stgit@ubuntu> <20130114162415.GF23505@n2100.arm.linux.org.uk> Date: Mon, 14 Jan 2013 12:33:05 -0500 Message-ID: Subject: Re: [PATCH v5 03/14] KVM: ARM: Initial skeleton to compile KVM support From: Christoffer Dall To: Russell King - ARM Linux Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Marc Zyngier , Marcelo Tosatti , Rusty Russell X-Gm-Message-State: ALoCoQkzqwZhHsLsBkMUvKWAzDfy41qk6SdppDHdZSLKKCJqNs1FAUfn39T0qbilDpJHR+BnIW1J Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Jan 14, 2013 at 11:24 AM, Russell King - ARM Linux wrote: > On Tue, Jan 08, 2013 at 01:38:55PM -0500, Christoffer Dall wrote: >> + /* -ENOENT for unknown features, -EINVAL for invalid combinations. */ >> + for (i = 0; i < sizeof(init->features)*8; i++) { >> + if (init->features[i / 32] & (1 << (i % 32))) { > > Isn't this an open-coded version of test_bit() ? indeed, nicely spotted: commit 608588674144e403ad0ea3c93066f3175bd5cf88 Author: Christoffer Dall Date: Mon Jan 14 12:30:07 2013 -0500 KVM: ARM: Use test-bit instead of open-coded version Makes the code more readable, also adds spaces around the asterisk. Cc: Russell King Signed-off-by: Christoffer Dall --- Thanks, -Christoffer -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c index 65ae563..2339d96 100644 --- a/arch/arm/kvm/guest.c +++ b/arch/arm/kvm/guest.c @@ -193,8 +193,8 @@ int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES); /* -ENOENT for unknown features, -EINVAL for invalid combinations. */ - for (i = 0; i < sizeof(init->features)*8; i++) { - if (init->features[i / 32] & (1 << (i % 32))) { + for (i = 0; i < sizeof(init->features) * 8; i++) { + if (test_bit(i, (void *)init->features)) { if (i >= KVM_VCPU_MAX_FEATURES) return -ENOENT; set_bit(i, vcpu->arch.features);