Fixes for libcacard (usb smartcard emulation), xhci and uhci.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJUT3J4AAoJEEy22O7T6HE4CXoQAKII8pelQ7DuP6OgrkFzQ1h5 W17Nx/0mwsw7OatTNgV9uwdFp9zojZBIw15XPJSG2tbaf5Cc+f8rTU9x4W78xDzm Q2jgD0UXQm/cQVseUbCc3aDiP0g4N73E4PhkaYbTEk2/wctDkxV0ILNhJBWVtx/A q4qAB+9jVhgYY61JSwSxHSneSe8hu3Gos7y40J/lqwEvd3yzY0G/uXF1myw5NNf9 KFFjSOloLtoO/FaYg4VRY3e7QpMj2YlyytbDaG4+SMOzfZ6+P8thMbG3tWBDTSz0 ggghS85cL7BBH8bCvatvVhL8YPqrt8k8eP4UkdaTL3ZnHjlW2/RFbHw6oao+//ev QOmXuAkuwH2HUAo1PUgmKmC3cHGuCiOYlNvsTQ87LBTLLCt822ugD1wZUgCleXpd 1U6q9wxFeW65mKRrkC3JFCp2ljFgb4oxN6e4k0C1Naz4QKQjBKZTJWoTxzt6U56s ZnivZETvtP9TV1q8j09Hx/r8+sIG8UqFK84EMMQ8dglYdsTZB8TgzUebyUy6RiYE 2ahNi35UDn2oW+NE3Eof4p8SO1Cxas/p9ylfJZZJ0EaMJkr5AJ0KBgW4i7Lz/WPQ Jy/DlmIyiipz0C/LL+tl8m4l/CtdhhZqeI4G/doJ6BxYZ0qH+pPyxC7BpK1ySUzs kMm7LrIkhVoTQ7pwpsN7 =uT+E -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20141028-1' into staging Fixes for libcacard (usb smartcard emulation), xhci and uhci. # gpg: Signature made Tue 28 Oct 2014 10:39:52 GMT using RSA key ID D3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" * remotes/kraxel/tags/pull-usb-20141028-1: uhci: remove useless DEBUG xhci: add property to turn on/off streams support libcacard: don't free sign buffer while sign op is pending libcacard: Lock NSS cert db when selecting an applet on an emulated card libcacard: introduce new vcard_emul_logout Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
f33f43bd86
@ -35,9 +35,6 @@
|
||||
#include "trace.h"
|
||||
#include "qemu/main-loop.h"
|
||||
|
||||
//#define DEBUG
|
||||
//#define DEBUG_DUMP_DATA
|
||||
|
||||
#define FRAME_TIMER_FREQ 1000
|
||||
|
||||
#define FRAME_MAX_LOOPS 256
|
||||
|
@ -459,6 +459,7 @@ struct XHCIState {
|
||||
uint32_t numintrs;
|
||||
uint32_t numslots;
|
||||
uint32_t flags;
|
||||
uint32_t max_pstreams_mask;
|
||||
|
||||
/* Operational Registers */
|
||||
uint32_t usbcmd;
|
||||
@ -500,6 +501,7 @@ enum xhci_flags {
|
||||
XHCI_FLAG_USE_MSI_X,
|
||||
XHCI_FLAG_SS_FIRST,
|
||||
XHCI_FLAG_FORCE_PCIE_ENDCAP,
|
||||
XHCI_FLAG_ENABLE_STREAMS,
|
||||
};
|
||||
|
||||
static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
|
||||
@ -1384,7 +1386,7 @@ static void xhci_init_epctx(XHCIEPContext *epctx,
|
||||
epctx->pctx = pctx;
|
||||
epctx->max_psize = ctx[1]>>16;
|
||||
epctx->max_psize *= 1+((ctx[1]>>8)&0xff);
|
||||
epctx->max_pstreams = (ctx[0] >> 10) & 0xf;
|
||||
epctx->max_pstreams = (ctx[0] >> 10) & epctx->xhci->max_pstreams_mask;
|
||||
epctx->lsa = (ctx[0] >> 15) & 1;
|
||||
if (epctx->max_pstreams) {
|
||||
xhci_alloc_streams(epctx, dequeue);
|
||||
@ -2956,9 +2958,9 @@ static uint64_t xhci_cap_read(void *ptr, hwaddr reg, unsigned size)
|
||||
break;
|
||||
case 0x10: /* HCCPARAMS */
|
||||
if (sizeof(dma_addr_t) == 4) {
|
||||
ret = 0x00087000;
|
||||
ret = 0x00080000 | (xhci->max_pstreams_mask << 12);
|
||||
} else {
|
||||
ret = 0x00087001;
|
||||
ret = 0x00080001 | (xhci->max_pstreams_mask << 12);
|
||||
}
|
||||
break;
|
||||
case 0x14: /* DBOFF */
|
||||
@ -3590,6 +3592,11 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
|
||||
if (xhci->numslots < 1) {
|
||||
xhci->numslots = 1;
|
||||
}
|
||||
if (xhci_get_flag(xhci, XHCI_FLAG_ENABLE_STREAMS)) {
|
||||
xhci->max_pstreams_mask = 7; /* == 256 primary streams */
|
||||
} else {
|
||||
xhci->max_pstreams_mask = 0;
|
||||
}
|
||||
|
||||
xhci->mfwrap_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_mfwrap_timer, xhci);
|
||||
|
||||
@ -3853,6 +3860,8 @@ static Property xhci_properties[] = {
|
||||
XHCIState, flags, XHCI_FLAG_SS_FIRST, true),
|
||||
DEFINE_PROP_BIT("force-pcie-endcap", XHCIState, flags,
|
||||
XHCI_FLAG_FORCE_PCIE_ENDCAP, false),
|
||||
DEFINE_PROP_BIT("streams", XHCIState, flags,
|
||||
XHCI_FLAG_ENABLE_STREAMS, true),
|
||||
DEFINE_PROP_UINT32("intrs", XHCIState, numintrs, MAXINTRS),
|
||||
DEFINE_PROP_UINT32("slots", XHCIState, numslots, MAXSLOTS),
|
||||
DEFINE_PROP_UINT32("p2", XHCIState, numports_2, 4),
|
||||
|
@ -115,6 +115,7 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
|
||||
VCardAppletPrivate *applet_private;
|
||||
int size, next;
|
||||
unsigned char *sign_buffer;
|
||||
bool retain_sign_buffer = FALSE;
|
||||
vcard_7816_status_t status;
|
||||
VCardStatus ret = VCARD_FAIL;
|
||||
|
||||
@ -178,6 +179,7 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
|
||||
pki_applet->sign_buffer = sign_buffer;
|
||||
pki_applet->sign_buffer_len = size;
|
||||
*response = vcard_make_response(VCARD7816_STATUS_SUCCESS);
|
||||
retain_sign_buffer = TRUE;
|
||||
break;
|
||||
case 0x00:
|
||||
/* we now have the whole buffer, do the operation, result will be
|
||||
@ -200,9 +202,11 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
|
||||
VCARD7816_STATUS_ERROR_P1_P2_INCORRECT);
|
||||
break;
|
||||
}
|
||||
g_free(sign_buffer);
|
||||
pki_applet->sign_buffer = NULL;
|
||||
pki_applet->sign_buffer_len = 0;
|
||||
if (!retain_sign_buffer) {
|
||||
g_free(sign_buffer);
|
||||
pki_applet->sign_buffer = NULL;
|
||||
pki_applet->sign_buffer_len = 0;
|
||||
}
|
||||
ret = VCARD_DONE;
|
||||
break;
|
||||
case CAC_READ_BUFFER:
|
||||
|
@ -250,6 +250,11 @@ void
|
||||
vcard_select_applet(VCard *card, int channel, VCardApplet *applet)
|
||||
{
|
||||
assert(channel < MAX_CHANNEL);
|
||||
|
||||
/* If using an emulated card, make sure to log out of any already logged in
|
||||
* session. */
|
||||
vcard_emul_logout(card);
|
||||
|
||||
card->current_applet[channel] = applet;
|
||||
/* reset the applet */
|
||||
if (applet && applet->reset_applet) {
|
||||
|
@ -40,6 +40,7 @@ int vcard_emul_get_login_count(VCard *card);
|
||||
/* login into the card, return the 7816 status word (sw2 || sw1) */
|
||||
vcard_7816_status_t vcard_emul_login(VCard *card, unsigned char *pin,
|
||||
int pin_len);
|
||||
void vcard_emul_logout(VCard *card);
|
||||
|
||||
/*
|
||||
* key functions
|
||||
|
@ -401,7 +401,7 @@ vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)
|
||||
}
|
||||
|
||||
void
|
||||
vcard_emul_reset(VCard *card, VCardPower power)
|
||||
vcard_emul_logout(VCard *card)
|
||||
{
|
||||
PK11SlotInfo *slot;
|
||||
|
||||
@ -409,15 +409,23 @@ vcard_emul_reset(VCard *card, VCardPower power)
|
||||
return;
|
||||
}
|
||||
|
||||
slot = vcard_emul_card_get_slot(card);
|
||||
if (PK11_IsLoggedIn(slot, NULL)) {
|
||||
PK11_Logout(slot); /* NOTE: ignoring SECStatus return value */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vcard_emul_reset(VCard *card, VCardPower power)
|
||||
{
|
||||
/*
|
||||
* if we reset the card (either power on or power off), we lose our login
|
||||
* state
|
||||
*/
|
||||
/* TODO: we may also need to send insertion/removal events? */
|
||||
slot = vcard_emul_card_get_slot(card);
|
||||
PK11_Logout(slot); /* NOTE: ignoring SECStatus return value */
|
||||
}
|
||||
vcard_emul_logout(card);
|
||||
|
||||
/* TODO: we may also need to send insertion/removal events? */
|
||||
}
|
||||
|
||||
static VReader *
|
||||
vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
|
||||
|
Loading…
Reference in New Issue
Block a user